tsilenzio Posted July 24, 2007 Share Posted July 24, 2007 Ok on my site for some reason if i dont emtpy a database then when i drop it and recreate it, it will have all the entrys still in it. So i was wondering if somone could help me determine some kind of script that will figure out how many tables there are, then emtpy them, after that drop the tables or is this impossible? - deathseaker Thanx in advance! Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 24, 2007 Author Share Posted July 24, 2007 *Bump* Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 24, 2007 Author Share Posted July 24, 2007 well here is the verzion i came up with... <?php require_once('config.php'); $result = mysql_list_tables($db_database); if (!$result) { print "DB Error, could not list tables\n"; print 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { $table = row[0]; $query = "TRUNCATE TABLE '$table'"; processQuery($query); $query = "DROP TABLE '$table'"; processQuery($query); } ?> processQuery connects to the database and does all that stuff for me.. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 24, 2007 Share Posted July 24, 2007 why? you can dump the whole database off a single line (or delete it) instead of dumping all the data also why truncate and then dump just dump also its more standard to do $result = mysql_list_tables($db_database) or die(mysql_error()); saves you code and same result Quote Link to comment Share on other sites More sharing options...
tsilenzio Posted July 24, 2007 Author Share Posted July 24, 2007 i explaiend on first post because the database i use on the site will READD the data once i drop the table and if i create it down the line it will READD whatever data was inside it for some reason =/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.