@@ -307,46 +307,38 @@ private function getRemoveColumnSQL(String $tableName, String $columnName): Stri
307
307
public function renameTable (String $ tableName , String $ newTableName )
308
308
{
309
309
$ sql = $ this ->getTableRenameSQL ($ tableName , $ newTableName );
310
- $ stmt = $ this ->pdo ->prepare ($ sql );
311
- return $ stmt ->execute ();
310
+ return $ this ->query ($ sql );
312
311
}
313
312
314
313
public function renameColumn (String $ tableName , String $ columnName , ReflectedColumn $ newColumn )
315
314
{
316
315
$ sql = $ this ->getColumnRenameSQL ($ tableName , $ columnName , $ newColumn );
317
- $ stmt = $ this ->pdo ->prepare ($ sql );
318
- return $ stmt ->execute ();
316
+ return $ this ->query ($ sql );
319
317
}
320
318
321
319
public function retypeColumn (String $ tableName , String $ columnName , ReflectedColumn $ newColumn )
322
320
{
323
321
$ sql = $ this ->getColumnRetypeSQL ($ tableName , $ columnName , $ newColumn );
324
- $ stmt = $ this ->pdo ->prepare ($ sql );
325
- return $ stmt ->execute ();
322
+ return $ this ->query ($ sql );
326
323
}
327
324
328
325
public function setColumnNullable (String $ tableName , String $ columnName , ReflectedColumn $ newColumn )
329
326
{
330
327
$ sql = $ this ->getSetColumnNullableSQL ($ tableName , $ columnName , $ newColumn );
331
- $ stmt = $ this ->pdo ->prepare ($ sql );
332
- return $ stmt ->execute ();
328
+ return $ this ->query ($ sql );
333
329
}
334
330
335
331
public function addColumnPrimaryKey (String $ tableName , String $ columnName , ReflectedColumn $ newColumn )
336
332
{
337
333
$ sql = $ this ->getSetColumnPkConstraintSQL ($ tableName , $ columnName , $ newColumn );
338
- $ stmt = $ this ->pdo ->prepare ($ sql );
339
- $ stmt ->execute ();
334
+ $ this ->query ($ sql );
340
335
if ($ this ->canAutoIncrement ($ newColumn )) {
341
336
$ sql = $ this ->getSetColumnPkSequenceSQL ($ tableName , $ columnName , $ newColumn );
342
- $ stmt = $ this ->pdo ->prepare ($ sql );
343
- $ stmt ->execute ();
337
+ $ this ->query ($ sql );
344
338
$ sql = $ this ->getSetColumnPkSequenceStartSQL ($ tableName , $ columnName , $ newColumn );
345
- $ stmt = $ this ->pdo ->prepare ($ sql );
346
- $ stmt ->execute ();
339
+ $ this ->query ($ sql );
347
340
$ sql = $ this ->getSetColumnPkDefaultSQL ($ tableName , $ columnName , $ newColumn );
348
- $ stmt = $ this ->pdo ->prepare ($ sql );
349
- $ stmt ->execute ();
341
+ $ this ->query ($ sql );
350
342
}
351
343
return true ;
352
344
}
@@ -355,57 +347,55 @@ public function removeColumnPrimaryKey(String $tableName, String $columnName, Re
355
347
{
356
348
if ($ this ->canAutoIncrement ($ newColumn )) {
357
349
$ sql = $ this ->getSetColumnPkDefaultSQL ($ tableName , $ columnName , $ newColumn );
358
- $ stmt = $ this ->pdo ->prepare ($ sql );
359
- $ stmt ->execute ();
350
+ $ this ->query ($ sql );
360
351
$ sql = $ this ->getSetColumnPkSequenceSQL ($ tableName , $ columnName , $ newColumn );
361
- $ stmt = $ this ->pdo ->prepare ($ sql );
362
- $ stmt ->execute ();
352
+ $ this ->query ($ sql );
363
353
}
364
354
$ sql = $ this ->getSetColumnPkConstraintSQL ($ tableName , $ columnName , $ newColumn );
365
- $ stmt = $ this ->pdo ->prepare ($ sql );
366
- $ stmt ->execute ();
355
+ $ this ->query ($ sql );
367
356
return true ;
368
357
}
369
358
370
359
public function addColumnForeignKey (String $ tableName , String $ columnName , ReflectedColumn $ newColumn )
371
360
{
372
361
$ sql = $ this ->getAddColumnFkConstraintSQL ($ tableName , $ columnName , $ newColumn );
373
- $ stmt = $ this ->pdo ->prepare ($ sql );
374
- return $ stmt ->execute ();
362
+ return $ this ->query ($ sql );
375
363
}
376
364
377
365
public function removeColumnForeignKey (String $ tableName , String $ columnName , ReflectedColumn $ newColumn )
378
366
{
379
367
$ sql = $ this ->getRemoveColumnFkConstraintSQL ($ tableName , $ columnName , $ newColumn );
380
- $ stmt = $ this ->pdo ->prepare ($ sql );
381
- return $ stmt ->execute ();
368
+ return $ this ->query ($ sql );
382
369
}
383
370
384
371
public function addTable (ReflectedTable $ newTable )
385
372
{
386
373
$ sql = $ this ->getAddTableSQL ($ newTable );
387
- $ stmt = $ this ->pdo ->prepare ($ sql );
388
- return $ stmt ->execute ();
374
+ return $ this ->query ($ sql );
389
375
}
390
376
391
377
public function addColumn (String $ tableName , ReflectedColumn $ newColumn )
392
378
{
393
379
$ sql = $ this ->getAddColumnSQL ($ tableName , $ newColumn );
394
- $ stmt = $ this ->pdo ->prepare ($ sql );
395
- return $ stmt ->execute ();
380
+ return $ this ->query ($ sql );
396
381
}
397
382
398
383
public function removeTable (String $ tableName )
399
384
{
400
385
$ sql = $ this ->getRemoveTableSQL ($ tableName );
401
- $ stmt = $ this ->pdo ->prepare ($ sql );
402
- return $ stmt ->execute ();
386
+ return $ this ->query ($ sql );
403
387
}
404
388
405
389
public function removeColumn (String $ tableName , String $ columnName )
406
390
{
407
391
$ sql = $ this ->getRemoveColumnSQL ($ tableName , $ columnName );
392
+ return $ this ->query ($ sql );
393
+ }
394
+
395
+ private function query (String $ sql ): bool
396
+ {
408
397
$ stmt = $ this ->pdo ->prepare ($ sql );
398
+ //echo "- $sql -- []\n";
409
399
return $ stmt ->execute ();
410
400
}
411
401
}
0 commit comments