Php imports the. SQL file to the mysql database. Php import. SQL file to mysql database php Tutorial import. SQL file to mysql tutorial database tutorial set_time_limit (0); set the timeout time to 0, indicating that the operation is always executed. When php imports the. SQL file to the mysql database in safemode php
Php Tutorial import. SQL file to mysql tutorial database tutorial
Set_time_limit (0); // Set the timeout value to 0, indicating that the operation is always executed. If php is invalid in safe mode, the import may Time Out. in this case, you need to import data in multiple parts.
$ Db = new mysql ($ location ['host'], $ location ['hostname'], $ location ['hostpass'], $ location ['table'], "utf8", $ location ['ztime']);
$ Fp = @ fopen ($ SQL, "r") or die ("You cannot open an SQL file $ SQL"); // open a file
While ($ SQL = getnextsql ()){
Mysql_query ($ SQL );
}
// Echo "user data import completed! ";
Fclose ($ fp) or die ("can't close file $ file_name"); // close the file
// Obtain the SQL statement from the file one by one
Function getnextsql (){
Global $ fp;
$ SQL = "";
While ($ line = @ fgets ($ fp, 40960 )){
$ Line = trim ($ line );
// The following three statements are not required in the php version. you may need to modify them in some earlier versions.
// $ Line = str_replace ("\", "\", $ line );
// $ Line = str_replace ("'", "'", $ line );
// $ Line = str_replace ("\ r \ n", chr (13). chr (10), $ line );
// $ Line = stripcslashes ($ line );
If (strlen ($ line)> 1 ){
If ($ line [0] = "-" & $ line [1] = "-"){
Continue;
}
}
$ SQL. = $ line. chr (13). chr (10 );
If (strlen ($ line)> 0 ){
If ($ line [strlen ($ line)-1] = ";"){
Break;
}
}
}
Return $ SQL;
}
?>
Http://www.bkjia.com/PHPjc/630813.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630813.htmlTechArticlephp import. SQL file to mysql database php Tutorial import. SQL file to mysql tutorial database tutorial set_time_limit (0); // Set the time-out time to 0, indicating that the execution has been ongoing. When php is in safe mode...