Just want to study how to back up the database, share a PHP implementation of MySQL backup class library
Query ("SHOW CREATE TABLE $table"); $create = $db->fetch_row ($createtable); $tabledump. = $create [1]. "; N\n "; return $tabledump; /****** back up the database structure and all data ******//* Function name: Data2sql () function: Convert table structure and data into SQL function parameters: $table: The name of the table to extract Return value: Returns the extracted result, SQL aggregate function Author: Heiyeluren */function Data2sql ($table) {global $db; $tabledump = "DROP TABLE IF EXISTS $table; \ n"; $createtable = $db->query ("SHOW CREATE TABLE $table"); $create = $db->fetch_row ($createtable); $tabledump. = $create [1]. "; N\n "; $rows = $db->query ("SELECT * from $table"); $numfields = $db->num_fields ($rows); $numrows = $db->num_rows ($rows); while ($row = $db->fetch_row ($rows)) {$comma = ""; $tabledump. = "INSERT into $table VALUES ("; for ($i = 0; $i < $numfields; $i + +) {$tabledump. = $cOmma. "'". Mysql_escape_string ($row [$i]). "'"; $comma = ","; } $tabledump. = "); \ n"; } $tabledump. = "\ n"; return $tabledump; }?>
The above describes the PHP written to implement the MySQL backup class library, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.