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