When an equivalent operation SQL statement, such as a large number of data into the database, the original type of execution of SQL statements or bulk execution of SQL statements, it is obviously not feasible, because whether it is a single execution or bulk execution will be continuous send SQL statements to the database, The database is compiled with SQL statements, resulting in efficiency.
The pre-compilation that appears in PHP solves this problem, and he works by sending SQL statements to the database to pre-compile the SQL statement. Then you just need to send the data to the database.
Here's an official example to illustrate the situation:
<?php$mysqli = new mysqli (' localhost ', ' my_user ', ' My_password ', ' world ');/* Check connection */if (mysqli_connect_ errno ()) { printf ("Connect failed:%s\n", Mysqli_connect_error ()); Exit ();} $stmt = $mysqli->prepare ("INSERT into Countrylanguage VALUES (?,?,?,?)");
Where $mysqli->prepare is pre-compiled with SQL statements,
$stmt->bind_param is a parameter binding. The first parameter above refers to the data type of all parameters.
$stmt->execute (); is an insert operation.
If you need to insert multiple data, you only need to manipulate $stmt->bind_param and $stmt->execute ();