Skip to content

Instantly share code, notes, and snippets.

@sakydev
Last active September 3, 2021 09:29
Show Gist options
  • Save sakydev/280d352d725765885f5fd054d1e448a8 to your computer and use it in GitHub Desktop.
Save sakydev/280d352d725765885f5fd054d1e448a8 to your computer and use it in GitHub Desktop.
php+mysql: script to run same command on multiple tables
<?php
$query = "alter table {table} drop column columnName;";
$tables = array('tableA', 'tableB');
foreach ($tables as $key => $source) {
    $currentQuery = str_replace('{table}', $source, $query);
    DB::query($currentQuery);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment