Comparison of mysql_connect/mysql_pconnect for php-mysql extension_PHP tutorial

WBOY
Release: 2016-07-14 10:06:43
Original
1064 people have browsed it

author: selfimpr
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 marks whether to create a new resource object
resource mysql_pconnect($host_port, $user, $passwd, $client_flags);
allow_persistent directive
Set this directive to make both functions behave the same as mysql_connect()
Get the connection resource object
Find the hash value of $host_port, $user, $passwd, $client_flags
Find the connection object in the regular resource list (EG(regular_list)) (found and $newlink is not set to force the creation of a new connection)
Check if the found object is of resource type
Read the connection object from the found object
Set the currently acquired connection object as the global default connection object
Increase the reference count of the connection object and set the zval attribute to return
Find the hash value of $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 directive limit is reached
Check whether the max_persistent configuration directive limit is reached
Allocate connection object (php_mysql_conn) space
Set the basic properties of the connection object
Initialize the driver layer connection object (mysqlnd/libmysql two methods)
Set connection timeout
Initiate a real connection request from the driver layer
Construct a persistent 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
Register resource type return value
Set the currently acquired connection as the global default connection object
Find the hash value of $host_port, $user, $passwd, $client_flags
Find the connection object in the regular resource list (EG(regular_list)) (not found or $newlink is set to force the creation of a new connection)
Check max_links configuration directive limits
Allocate connection object (php_mysql_conn) space
Set the basic properties of the connection object
Initialize the driver layer connection object (mysqlnd/libmysql)
Set connection timeout
Initiate a real connection to the driver layer
Register the 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 acquired connection object as the global default connection object
Find the hash value of $host_port, $user, $passwd, $client_flags
Find the connection object from the persistent resource list (found)
Check whether the type of the found persistent resource matches
Read the connection object from the persistent resource
Set the basic properties of the connection object
Check whether the server is actively shut down
If the server actively closes, reconnect
Register 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 the execution global environment executor_globals
The life cycles of the two are different. regular_list is released when php_request_shutdown(), that is, it is released after a single request is processed, while persistent_list is released by calling zend_shutdown() when php_module_shutdown(), that is, it is released when the entire process completes execution


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477932.htmlTechArticleauthor: selfimpr 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, $n...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template