We know that mysqli is a new MySQL interface provided in PHP 5, which uses the object-oriented idea. The code using the mysqli interface is more readable, and its execution efficiency is higher than that of the mysql interface. In addition, mysqli provides a multi_query () function that can execute multiple SQL statements at a time. However, the mysqli interface only supports Versions later than PHP 5 and MySQL 4.1.
The query () function can only execute one SQL statement at a time, while the multi_query () function can execute multiple SQL statements at a time.
If the first SQL statement is correctly executed, the multi_query () function returns true; otherwise, false.
Use the store_result () function to obtain records of the multi_query () function for query execution. Only one SQL statement can be obtained at a time.
The next_result () function is used to determine whether the result of the next SQL statement exists. If yes, true is returned.
Example:
Copy codeThe Code is as follows: $ SQL = "select * from score; select * from student ";
$ Rs = $ connection-> multi_query ($ SQL );