@@ -115,7 +115,7 @@ public function dropDatabase(string $dbName): bool
115
115
* or column names to DROP
116
116
*
117
117
* @return array|string|null
118
- * @return list<string>|string|null SQL string or null
118
+ * @return bool| list<string>|string|null SQL execute result or null
119
119
* @phpstan-return ($alterType is 'DROP' ? string : list<string>|null)
120
120
*/
121
121
protected function _alterTable (string $ alterType , string $ table , $ processedFields )
@@ -126,13 +126,11 @@ protected function _alterTable(string $alterType, string $table, $processedField
126
126
127
127
$ sqlTable = new Table ($ this ->db , $ this );
128
128
129
- $ sqlExecuteResult = $ sqlTable ->fromTable ($ table )
129
+ return $ sqlTable ->fromTable ($ table )
130
130
->dropColumn ($ columnNamesToDrop )
131
131
->run ();
132
132
133
- // Return the execute result with string type.
134
- return '' . $ sqlExecuteResult ;
135
-
133
+ // Return the execute result with boolean type.
136
134
case 'CHANGE ' :
137
135
$ fieldsToModify = [];
138
136
@@ -153,18 +151,42 @@ protected function _alterTable(string $alterType, string $table, $processedField
153
151
$ fieldsToModify [] = $ field ;
154
152
}
155
153
156
- (new Table ($ this ->db , $ this ))
154
+ return (new Table ($ this ->db , $ this ))
157
155
->fromTable ($ table )
158
156
->modifyColumn ($ fieldsToModify )
159
157
->run ();
160
158
161
- return null ; // Why null?
162
-
163
159
default :
164
160
return parent ::_alterTable ($ alterType , $ table , $ processedFields );
165
161
}
166
162
}
167
163
164
+ /**
165
+ * @param array|string $columnNames column names to DROP
166
+ *
167
+ * @return bool
168
+ *
169
+ * @throws DatabaseException
170
+ */
171
+ public function dropColumn (string $ table , $ columnNames )
172
+ {
173
+ $ sqlExecuteResult = $ this ->_alterTable ('DROP ' , $ this ->db ->DBPrefix . $ table , $ columnNames );
174
+
175
+ if (is_bool ($ sqlExecuteResult ) === true ) {
176
+ if ($ sqlExecuteResult === false ) {
177
+ if ($ this ->db ->DBDebug ) {
178
+ throw new DatabaseException ('This feature is not available for the database you are using. ' );
179
+ }
180
+
181
+ return false ;
182
+ }
183
+
184
+ return $ sqlExecuteResult ;
185
+ }
186
+
187
+ return $ this ->db ->query ($ sqlExecuteResult );
188
+ }
189
+
168
190
/**
169
191
* Process column
170
192
*/
0 commit comments