Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Created August 12, 2018 21:30
Show Gist options
  • Save aleclarson/22eacd300851cc676bfa748acbff8892 to your computer and use it in GitHub Desktop.
Save aleclarson/22eacd300851cc676bfa748acbff8892 to your computer and use it in GitHub Desktop.
WordPress script for dropping tables based on their name
$tables = $wpdb->get_results("
SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'i9JAv_%';
");
$tables = array_map(function($tbl) {
return $tbl->table_name;
}, $tables);
$tables = implode(', ', $tables);
$wpdb->query("
DROP TABLE IF EXISTS $tables;
");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment