PHP learns the difference between MySQL and mysqli

Source: Internet
Author: User
Tags pconnect

(1) The difference between MySQL and mysqli is:

The MYSQLI connection is a permanent connection, and MySQL is a non-permanent connection.
MySQL connection: Whenever a second use occurs, a new process is reopened.
MYSQLI Connection: Always use only the same process.
Benefits: This can greatly reduce the pressure on the server .

(2) mysql_connect and Mysql_pconnect and Mysqli_connect:
Mysql_pconnect The open connection is not closed (even if the call to Mysql_close is not closed because it is not valid),
Similar to the connection buffer pool, if the next time there is the same user name from the same machine
For a connection to the same database, PHP automatically uses the last connection that was established, without having to re-establish one.
Benefit: Eliminates the overhead of establishing a connection to the database each time,
Cons : It is necessary to waste some memory, occupy some connections,
So if the user access to a large number of errors will occur, to the mysql max_connections parameter to a larger, or use mysql_connect () to solve the problem.

Connect and pconnect do not have functional differences, only performance differences.
Generally PHP has two modes of operation, one is to run as a CGI, the second is to run as an Apache module.
Is there no difference between connect and pconnect as a CGI? Because every time the CGI runs, it is destroyed to clean up resources.

PHP learns the difference between MySQL and mysqli

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.