Share a php MYSQL backup class library and a phpmysql backup class library
I just want to study how to back up the database and share a php class library for MYSQL backup.
<? Php/******* back up the database structure ******* // ***** it is just necessary to study how to back up the database, share a php class library for MYSQL backup ******** // function name: table2sql () function: Convert the table structure into SQL function parameters: $ table: Return Value of the table name to be extracted: return the extracted result. Author of the SQL set function: heiyeluren */function table2sql ($ 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"; return $ tab Ledump;}/******* back up the database structure and all data ****** // function name: data2sql () function: convert the table structure and data into SQL function parameters: $ table: Return Value of the table name to be extracted: return the extracted result. Author of the SQL set function: 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"; $ 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;}?>
Http://php.662p.com/thread-560-1-1.html