Skip to content

Instantly share code, notes, and snippets.

@iamajeesh
Created May 13, 2015 07:29
Show Gist options
  • Save iamajeesh/c97f3b31dde49c965daa to your computer and use it in GitHub Desktop.
Save iamajeesh/c97f3b31dde49c965daa to your computer and use it in GitHub Desktop.
Drop All Tables in Database Uisng PHP
<?php
$mysqli = new mysqli("localhost", "user", "pass", "dbname");
$mysqli->query('SET foreign_key_checks = 0');
if ($result = $mysqli->query("SHOW TABLES"))
{
while($row = $result->fetch_array(MYSQLI_NUM))
{
$mysqli->query('DROP TABLE IF EXISTS '.$row[0]);
echo $row[0].",\n";
}
}
$mysqli->query('SET foreign_key_checks = 1');
$mysqli->close();
?>
Copy link

ghost commented Feb 10, 2021

woooooooooooooooooooooorking, thanks :D

@jaydipshingala
Copy link

This is working Fine. Thanks!!

@akashverma107
Copy link

Awsome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment