note 56586 added to function.mysql-field-flags
| From: | bomas at cities-of-faith dot com | Date: | Thu, 08 Sep 2005 08:52:43 +0000 |
| Subject: | note 56586 added to function.mysql-field-flags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94896@lists.php.net to get a copy of this message | ||
well, to make a complete backup of your database, i suggest this code:
//open database here
$tab_status = mysql_query("SHOW TABLE STATUS");
while($all = mysql_fetch_assoc($tab_status)):
$tbl_stat[$all[Name]] = $all[Auto_increment];
endwhile;
unset($backup);
$tables = mysql_list_tables('cofadmin');
while($tabs = mysql_fetch_row($tables)):
$backup .= "--\n--Tabel structuur voor
$tabs[0]\n--\n\nDROP IF EXISTS TABLE
$tabs[0]\nCREATE TABLE IF NOT EXISTS $tabs[0] ( ";
$res = mysql_query("SHOW CREATE TABLE $tabs[0]");
while($all = mysql_fetch_assoc($res)):
$str = str_replace("CREATE TABLE $tabs[0] (", "",
$all['Create Table']);
$str = str_replace(",", ", ", $str);
$str2 = str_replace(") ) TYPE=MyISAM ", ")\n ) TYPE=MyISAM ",
$str);
$backup .= $str2." AUTO_INCREMENT=".$tbl_stat[$tabs[0]].";\n\n";
endwhile;
$backup .= "--\n--Gegevens worden uitgevoerd voor tabel $tabs[0]\n--\n\n";
$data = mysql_query("SELECT * FROM $tabs[0]");
while($dt = mysql_fetch_row($data)):
$backup .= "INSERT INTO $tabs[0] VALUES('$dt[0]'";
for($i=1; $i<sizeof($dt); $i++):
$backup .= ", '$dt[$i]'";
endfor;
$backup .= ");\n";
endwhile;
$backup .= "\n-- --------------------------------------------------------\n\n";
endwhile;
echo $backup;
this displayes your data the same way as phpmyadmin does.
hope it helps some of you guys
Greetz
----
Manual Page -- http://www.php.net/manual/en/function.mysql-field-flags.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56586
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56586&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56586&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56586&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56586&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56586&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56586&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56586&report=yes
Search -- http://master.php.net/manage/user-notes.php