Looking to generate a backup of all tables using php without any data from the tables. How can this be done. A hot rush for me to get this going. Thanks, TJ
No complaints, lol. Well, the basic idea is as such: Get a list of all tables; loop through this list, selecting each table take the contents of the currently selected table and save it. How you want to save it is up to you.
I was more or less looking for a code to process it. The data does not need to be saved. Only the structure. TJ
Here's some code to fetch an then recreate some db structure: $dbServer = "localhost"; $dbUserName = "root"; $dbPassword = ""; $dbName = "somedb"; $conn = mysql_connect($dbServer, $dbUserName, $dbPassword); // select db information_schema mysql_select_db('information_schema', $conn); $tables = array(); $sql="SELECT table_name FROM `TABLES` T where table_schema='$dbName';"; $res = mysql_query($sql, $conn); while($t = mysql_fetch_assoc($res)) { $tables[] = $t['table_name']; } // select your db mysql_select_db($dbName, $conn); // fetch structure $db_structure = array(); foreach($tables as $table_name) { $sql="SHOW CREATE TABLE " . $table_name ; $res = mysql_query($sql, $conn); $ts = mysql_fetch_assoc($res); $db_structure[] = $ts["Create Table"]; } print_r($db_structure); PHP: It works for me.