What interfaces (mysql and mysqli) are selected in php to access mysql?

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.