Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Created September 12, 2017 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryhughes/863dcf59c08a793681cfcead20c8e3da to your computer and use it in GitHub Desktop.
Save barryhughes/863dcf59c08a793681cfcead20c8e3da to your computer and use it in GitHub Desktop.
Helper script to drop a bunch of imported tables from a WP test site.
<?php
/**
* Drop a bunch of tables.
*
* Update the prefix in the foreach definition then run via WP-CLI,
* ie "wp eval-file ../path/to/this-script.php".
*/
global $wpdb;
foreach ( $wpdb->get_col( "SHOW TABLES LIKE 'customer_db_%'" ) as $table ) {
$wpdb->query( $wpdb->prepare( 'DROP TABLE %s', $table ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment