Comparison of mysql_connect/mysql_pconnect extensions of php-mysql

Source: Internet
Author: User
Author: selfimprblog: Login ($ host_port, $ user, $ passw

Author: selfimip
Blog: http://blog.csdn.net/lgg201
Mail: lgg860911@yahoo.com.cn

Item
Mysql_connect
Mysql_pconnect
Function prototype
Resource mysql_connect ($ host_port, $ user, $ passwd, $ newlink, $ client_flags );
The fourth parameter $ newlink indicates whether to create a new resource object.
Resource mysql_pconnect ($ host_port, $ user, $ passwd, $ client_flags );
Allow_persistent command
Set this command to make the two functions behave the same as mysql_connect ().
Obtain the connection resource object
Evaluate the hash value for $ host_port, $ user, $ passwd, $ client_flags
Find the connection object in the normal Resource List (EG (regular_list) (The connection object has been found and $ newlink is not set to force new connections)
Check whether the object is a resource type.
Read the connection object from the searched object
Set the currently obtained connection object to the global default connection object.
Increase the reference count of the connection object and set the zval attribute to return
Evaluate the hash value for $ host_port, $ user, $ passwd, $ client_flags
Find the connection object from the persistent resource list (EG (persist_list) (not found)
Check whether the max_links configuration command limit has been reached
Check whether the max_persistent configuration command limit has been reached
Allocate the space of the connection object (php_mysql_conn)
Set basic properties of the connection object
Initialize the connection object of the driver layer (mysqlnd/libmysql)
Set connection timeout
Initiate a real connection request for the driver layer
Construct a persistence list element object and set the new connection object to the element.
Update the connection object to the persistence list.
Update (increase) num_persistent/num_links count
Registered resource type return value
Set the currently obtained connection as the global default connection object
Evaluate the hash value for $ host_port, $ user, $ passwd, $ client_flags
Find the connection object in the normal Resource List (EG (regular_list) (The connection object is not found or $ newlink is set to force new connections)
Check max_links configuration command limits
Allocate the space of the connection object (php_mysql_conn)
Set basic properties of the connection object
Initialize the connection object of the driver layer (mysqlnd/libmysql)
Set connection timeout
Initiate a real connection to the driver layer
Register a connection object as a resource type return value
Update the connection object to the normal Resource List (EG (regualr_list ).
Update num_links count
Set the currently obtained connection object to the global default connection object.
Evaluate the hash value for $ host_port, $ user, $ passwd, $ client_flags
Find the connection object from the persistent resource list (found)
Check whether the type of the persistent resource found matches
Read connection objects from persistent resources
Set basic properties of a connection object
Check whether the server is automatically disabled
Re-connect if the server is disabled.
Registered resource type return value
Set the currently obtained connection as the global default connection object
Regular_list Vs. persistent_list
Both regular_list and persistent_list are HashTable.
Both are members of executor_globals in the global environment.
The lifecycle is different between the two. regular_list is released at php_request_shutdown (), that is, after a single request is processed, it is released. persistent_list calls zend_shutdown () for release at php_module_shutdown, that is, release when the entire process is completed.


 

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.