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
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");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.