|
Posted by Renι Vaessen on 07/25/07 01:51
<laredotornado@zipmail.com> schreef in bericht
news:1184777424.702095.282450@z24g2000prh.googlegroups.com...
> Hi,
>
> I'm using php 4.4.4 with MySQL 5.0 on Linux. Short of dropping the
> database, which my user does not have privileges to, what is the
> simplest way to purge all data from the db? By this I mean not only
> deleting data from tables but also the tables themselves?
>
> Thanks, - Dave
>
Try this script
$db=mysql_connect($host,$user,$pass) or die ("verbinding mislukt");
mysql_select_db($datab,$db);
$blaat = mysql_list_tables ($datab);
$tbl = array();
while ($row = mysql_fetch_row($blaat))
$tbl[] = $row[0];
$dit = 'DROP TABLE ';
for ($a=0; $a < count($tbl); $a++) {
$dit .= '`'.$tbl[$a].'`';
if ($a < (count($tbl) - 1))
$dit .= ', ';
}
$exec = mysql_query($dit) or die (mysql_error());
Grtz,
Renι
Navigation:
[Reply to this message]
|