Jump to content

Emptying entire database


86Stang

Recommended Posts

101 question here...

 

I need to erase all data from the database before running an import.  Don't ask - it's management's decision.  Anyway, could someone school me in the ways to erase all data in the DB from a php file?  I'm already connected to the DB, can import, etc., I just need to figure out how to flush the current data first.

Link to comment
https://forums.phpfreaks.com/topic/49565-emptying-entire-database/
Share on other sites

put all the names of the tabes in an array and  use truncate. im a noobie but im sure there is a way to query all the names of the tables to automate the array creation. goodluck!

 

 

$tables=array("grades","inclass","submitted","posted","classes");

foreach($tables as $table)

{

$query = "truncate  $table";

$result = mysql_query($query,$conn) or die("Query error");

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.