@@ -92,8 +92,10 @@ public static function create($tableName, callable $callback)
9292 {
9393 $ blueprint = new Blueprint ($ tableName );
9494 $ callback ($ blueprint );
95+
9596 $ result = $ blueprint ->handleBlueprint ();
9697 self ::$ lastResult = $ result ;
98+
9799 return $ result ;
98100 }
99101
@@ -191,11 +193,17 @@ public static function dropTable($tableName, $force = false)
191193
192194 // Handle query
193195 try {
194- // DROP TABLE IF EXISTS
196+
195197 if ($ force ){
196- self ::$ pdo ->exec ("SET FOREIGN_KEY_CHECKS = 0; " ); // Disable foreign key checks temporarily
197- self ::$ pdo ->exec ("DROP TABLE {$ tableName } CASCADE; " ); // Drop the table with CASCADE option
198- self ::$ pdo ->exec ("SET FOREIGN_KEY_CHECKS = 1; " ); // Enable foreign key checks again
198+ // Disable foreign key checks temporarily
199+ self ::$ pdo ->exec ("SET FOREIGN_KEY_CHECKS = 0; " );
200+
201+ if (self ::$ db ->tableExists ($ tableName )){
202+ // Drop the table with CASCADE option
203+ self ::$ pdo ->exec ("DROP TABLE {$ tableName } CASCADE; " );
204+ }
205+ // Enable foreign key checks again
206+ self ::$ pdo ->exec ("SET FOREIGN_KEY_CHECKS = 1; " );
199207 } else {
200208 self ::$ pdo ->query ( "DROP TABLE {$ tableName }; " )->execute ();
201209 }
@@ -227,11 +235,11 @@ public static function dropColumn($tableName, $columnName)
227235 {
228236 self ::initSchemaDatabase ();
229237
230- // handle error
231- $ handle = self :: checkDBConnect ();
232- if ( is_array ( $ handle )){
233- return $ handle ;
234- }
238+ $ conn = self :: checkDBConnect ();
239+ if ( $ conn [ ' status ' ] != Constant:: STATUS_200 ){
240+ self :: $ lastResult = $ conn ;
241+ return $ conn ;
242+ }
235243
236244 // if empty
237245 if (empty ($ columnName )){
0 commit comments