Is there a way to 'flush' the whole db so that all tables are deleted?
A few points:
-The db can't be dropped and recreated
-The names of the tables in the db are unknown
-I'm talking PHP/mySQL here.
Thanks for your time.
| SitePoint Sponsor |





Is there a way to 'flush' the whole db so that all tables are deleted?
A few points:
-The db can't be dropped and recreated
-The names of the tables in the db are unknown
-I'm talking PHP/mySQL here.
Thanks for your time.
www.nyanko.ws - My web-, software- and game development company.
www.mayaposch.com - My personal site and blog.





<?
$db = mysql_connect("localhost", "", "");
mysql_select_db("dbname");
$result = mysql_list_tables("dbname");
while($row=mysql_fetch_row($result)) {
$tmp = $row[0];
mysql_query("DROP TABLE $tmp");
$tmp ="";
}
?>
Please don't PM me with questions.
Use the forums, that is what they are here for.




Or you could do:
DROP * TABLES FROM database;
through telnet...correct?
<Edited by mkaufman on 01-07-2001 at 05:47 PM>





don't think so did you try it?
Please don't PM me with questions.
Use the forums, that is what they are here for.




No I didn't try it..just thought it would be easier then having to enter his username/password into your (no offense, it's a fine script) script and then uploading.





Matt I tried it and it doesn't work, also in his original request you motice the part about PHP/MySQL leads me to believe he wanted to do it from a script not the command line
-The db can't be dropped and recreated
-The names of the tables in the db are unknown
-I'm talking PHP/mySQL here.
Please don't PM me with questions.
Use the forums, that is what they are here for.





Thanks a lot, freddydoesphp!
That was exactly what I was looking for
BTW you were right, it's for use in a script.
I'm creating an installation script for my new site, and I want to save myself the trouble of deleting all temporary tables I've made in the db.
Maybe I'm just lazy![]()
www.nyanko.ws - My web-, software- and game development company.
www.mayaposch.com - My personal site and blog.
Bookmarks