note 90597 added to function.mysql-field-flags

From: Date: Wed, 29 Apr 2009 19:05:55 +0000
Subject: note 90597 added to function.mysql-field-flags
Groups: php.notes 
Request: Send a blank email to php-notes+get-154020@lists.php.net to get a copy of this message
there are a mistake in bomas@cities-of-faith.com example. I correct his example and in this version script save a backup file. //open database here $database = "namedb" $backup = ""; $backup = "-- Make Database $database --\n\n"; $backup .= "CREATE DATABASE $database DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;\n\n"; $tab_status = mysql_query("SHOW TABLE STATUS"); while($all = mysql_fetch_assoc($tab_status)) { $tbl_stat[$all["Name"]] = $all["Auto_increment"]; } $tables = mysql_list_tables($database); while($tabs = mysql_fetch_row($tables)){ $backup .= "-- Structure $tabs[0] --\n\n"; $res = mysql_query("SHOW CREATE TABLE $database.$tabs[0]"); while($all = mysql_fetch_assoc($res)){ $str = "CREATE TABLE IF NOT EXISTS $database.$tabs[0] ( ".str_replace("CREATE TABLE $tabs[0] (", "", $all['Create Table']); $str = str_replace(",", ", ", $str); $str2 = str_replace(") ) TYPE=MyISAM ", ")\n ) TYPE=MyISAM ", $str); $backup .= $str2.($tbl_stat[$tabs[0]] ? " AUTO_INCREMENT=".$tbl_stat[$tabs[0]] : "").";\n\n"; } $backup .= "-- Data $tabs[0] --\n\n"; $data = mysql_query("SELECT * FROM $database.$tabs[0]"); while($dt = mysql_fetch_row($data)){ $backup .= "INSERT INTO $database.$tabs[0] VALUES('$dt[0]'"; for($i=1; $i<sizeof($dt); $i++){ $backup .= ", '$dt[$i]'"; } $backup .= ");\n"; } $backup .= "\n-- --------------------------------------------------------\n\n"; } echo($backup); $file_backup = fopen("Backup_".date("d.m.Y").".sql","w"); fputs($file_backup,$backup); fclose($file_backup); ---- Server IP: 195.24.79.185 Probable Submitter: 92.250.137.94 ---- Manual Page -- http://www.php.net/manual/en/function.mysql-field-flags.php Edit -- https://master.php.net/note/edit/90597 Del: integrated -- https://master.php.net/note/delete/90597/integrated Del: useless -- https://master.php.net/note/delete/90597/useless Del: bad code -- https://master.php.net/note/delete/90597/bad+code Del: spam -- https://master.php.net/note/delete/90597/spam Del: non-english -- https://master.php.net/note/delete/90597/non-english Del: in docs -- https://master.php.net/note/delete/90597/in+docs Del: other reasons-- https://master.php.net/note/delete/90597 Reject -- https://master.php.net/note/reject/90597 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#154020) next »