Discussion on the difference between MySQL and mysqli in PHP _php skills

Source: Internet
Author: User
First of all, two functions are used to process db.
First, the MYSQLI connection is a permanent connection, and MySQL is a non permanent connection. What does that mean? The MySQL connection will reopen a new process whenever it is used for the second time, and Mysqli will only use the same process, which can greatly reduce server-side pressure.
Second, mysqli encapsulates some advanced operations, such as transactions, while encapsulating many of the methods available during the DB operation.
The most widely used place is the mysqli business.
Like the following example:
Copy Code code as follows:

$mysqli = new mysqli (' localhost ', ' root ', ' ', ' db_lib2test ');
$mysqli->autocommit (false);/Start Things
$mysqli->query ($sql 1);
$mysqli->query ($sql 2);
if (! $mysqli->errno) {
$mysqli->commit ();
echo ' OK ';
}else{
echo ' err ';
$mysqli->rollback ();
}


Related Article

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.