Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created April 21, 2009 08:11
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 itspriddle/99021 to your computer and use it in GitHub Desktop.
Save itspriddle/99021 to your computer and use it in GitHub Desktop.
<?php // drop wp_ tables
// Set to your db
$database = 'my_db';
// Add your user/pass
if ( ! mysql_connect('localhost', 'username', 'password'))
{
die("Couldn't connect to db. MySQL Error (".mysql_errno()."): ".mysql_error());
}
$res = mysql_query("SHOW TABLES FROM {$database}");
if (mysql_num_rows($res) > 0)
{
while ($r = mysql_fetch_array($res))
{
$table = $r['Tables_in_'.$database];
if (substr($table, 0, 3) == 'wp_')
{
if (mysql_query("DROP TABLE {$table}"))
{
echo "Deleted {$table}\n";
}
else
{
echo "Couldn't delete {$table}\n";
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment