On the difference between MySQL and mysqli in PHP _php tutorial

Source: Internet
Author: User
The first two functions are used to process the db.
First, the MYSQLI connection is a permanent connection, and MySQL is a non-permanent connection. What do you mean? The MySQL connection will reopen a new process whenever it is used for the second time, while Mysqli will only use the same process, which can greatly reduce the server-side pressure.
Second, mysqli encapsulates some advanced operations, such as transactions, while encapsulating many of the methods available in the DB operation process.
The most widely used place is the mysqli transaction.
such as the following example:
Copy CodeThe code is 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 ();
}
  

http://www.bkjia.com/PHPjc/327585.html www.bkjia.com true http://www.bkjia.com/PHPjc/327585.html techarticle the first two functions are used to process the db. First, the MYSQLI connection is a permanent connection, and MySQL is a non-permanent connection. What do you mean? MySQL connection whenever you use the second time, will ...

  • 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.