Jump to content

PHP to drop/clear/wipe mysql database so that all rows are deleted and the database is empty


james909

Recommended Posts

Something like this

$db = new mysqli(HOST,USERNAME,PASSWORD,'databasename');

$sql = "SHOW TABLES";
$res = $db->query($sql);
while ($row = $res->fetch_row()) {
    echo "$row[0]<br>";
    $sql2 = "TRUNCATE TABLE `$row[0]`";
    $db->query($sql2);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.