This is a backup of all the tables in the specified database to a SQL file that can be downloaded. The source code from the DEDECMS program, a lot of functions, but also very practical, but the quality of the codes need to be improved
-
-
- /****** backing up the database structure ******/
-
- /*
- function Name: Table2sql ()
- function function: Convert the structure of a table into SQL
- function Parameters: $table: The name of the table to extract
- return value: Returns the extracted result, SQL collection
- function Author: heiyeluren
- */
-
- function table2sql ($table)
- {
- Global $db;
- $tabledump = "DROP TABLE IF EXISTS $table;" ;
- $createtable = $db --->query ("SHOW CREATE TABLE $table");
- $create = $db ->fetch_row ($createtable);
- $tabledump .= $create [1]. ";" ;
- return $tabledump;
- }
-
-
- /****** backing up the database structure and all data ******/
- /*
- function Name: Data2sql ()
- function function: Convert the structure and data of a table into SQL
- function Parameters: $table: The name of the table to extract
- return value: Returns the extracted result, SQL collection
- function Author: heiyeluren
- */
- function data2sql ($table)
- {
- Global $db;
- $tabledump = "DROP TABLE IF EXISTS $table;" ;
- $createtable = $db ->query ("SHOW CREATE TABLE $table");
- $create = $db ->fetch_row ($createtable);
- $tabledump .= $create [1]. ";" ;
-
- $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 (";
- http://www.bkjia.com/PHPjc/486044.html www.bkjia.com true http://www.bkjia.com/PHPjc/486044.html techarticle This is a backup of all the tables in the specified database to a SQL file that can be downloaded. The source code from the DEDECMS program, a lot of functions, but also very practical, but the quality of the codes have yet to be improved ...
-