This article mainly introduces how to use php statements to import the database *. SQL file to the database. For more information, see the simplest php statement to import the database *. SQL file to the database.
The code is as follows:
$ SQL = file_get_contents ("text. SQL"); // read SQL statements in strings. $ SQL
$ A = explode (";", $ SQL); // Use The explode () function$ SQL string separated by ";" as an array
Foreach ($ a as $ B) {// traverses the array
$ C = $ B. ";"; // There is no ";" after the split. because the SQL statement ends with ";", add it before executing the SQL statement.
Mysql_query ($ c); // execute an SQL statement
}
In many installation programs, you will see the installation of the database. The other mysteries are just a few simple codes. First, an SQL file is installed and then executed in PHP according to the above code.