Home  >  Article  >  Backend Development  >  Which interface (mysql, mysqli) to choose in php to access mysql_PHP tutorial

Which interface (mysql, mysqli) to choose in php to access mysql_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:13:44825browse

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:

Copy code The code is as follows:

$sql="select * from score; select * from student ";
$rs=$connection->multi_query($sql);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326454.htmlTechArticleWe know that mysqli is a new MySQL interface provided in PHP 5. This interface uses object-oriented ideas. Code using the mysqli interface is more readable and its execution efficiency is higher than that of the mysql interface. And...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn