Home > Article > Backend Development > Which interface (mysql, mysqli) to choose in php to access mysql_PHP tutorial
We know that mysqli is a newly provided MySQL interface in PHP 5. This interface uses object-oriented thinking. Code using the mysqli interface is more readable and its execution efficiency is higher than that of the mysql interface. And mysqli provides a multi_query() function that can execute multiple SQL statements at one time. However, the mysqli interface only supports versions after 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 executed correctly, the multi_query() function returns true, otherwise it returns false.
Get the records of the query executed by the multi_query() function through the store_result() function. Only the execution result of one SQL statement can be obtained at a time.
Use the next_result() function to determine whether the result of the next SQL statement exists. If it exists, return true.
Example: