author: selfimpr
blog: http://blog.csdn.net/lgg201
mail: lgg860911@yahoo.com.cn
item
mysql_connect
mysql_pconnect
函数原型
resource mysql_connect($host_port, $user, $passwd, $newlink, $client_flags);
第四个参数$newlink标记是否创建新的资源对象
resource mysql_pconnect($host_port, $user, $passwd, $client_flags);
allow_persistent指令
设置此指令使得两个函数行为均和mysql_connect()一致
连接资源对象获取
对$host_port, $user, $passwd, $client_flags求哈希值
在普通资源列表(EG(regular_list))中查找连接对象(已找到并且没有设置$newlink强制创建新连接)
检查找到的对象是否资源类型
从查找到的对象中读取连接对象
将当前获取的连接对象设置为全局默认连接对象
增加连接对象的引用计数, 设置zval属性返回
对$host_port, $user, $passwd, $client_flags求哈希值
从持久化资源列表(EG(persist_list))中查找连接对象(没有找到)
检查max_links配置指令限制是否到达
检查max_persistent配置指令限制是否到达
分配连接对象(php_mysql_conn)空间
设置连接对象的基础属性
初始化驱动层连接对象(mysqlnd/libmysql两种方式)
设置连接超时时间
发起驱动层的真实连接请求
构造持久化列表元素对象, 将新连接对象设置到元素中
将连接对象更新到持久化列表中
更新(增加)num_persistent/num_links计数
注册资源类型返回值
将当前获取的连接设置为全局默认连接对象
对$host_port, $user, $passwd, $client_flags求哈希值
在普通资源列表(EG(regular_list))中查找连接对象(未找到或设置了$newlink强制创建新连接)
检查max_links配置指令限制
分配连接对象(php_mysql_conn)空间
设置连接对象基础属性
初始化驱动层连接对象(mysqlnd/libmysql)
设置连接超时时间
发起驱动层的真实连接
将连接对象注册为资源类型返回值
将连接对象更新到普通资源列表(EG(regualr_list))中
更新num_links计数
将当前获取的连接对象设置为全局默认连接对象
对$host_port, $user, $passwd, $client_flags求哈希值
从持久化资源列表中查找连接对象(已找到)
检查查找到的持久化资源的类型是否匹配
从持久化资源中读取连接对象
设置连接对象基本属性
检查服务端是否主动关闭
如果服务端主动关闭则进行重连
注册资源类型返回值
将当前获取的连接设置为全局默认连接对象
regular_list Vs. persistent_list
regular_list和persistent_list两者都是HashTable
两者都是执行全局环境executor_globals的成员
两者生命周期不同, regular_list在php_request_shutdown()时被释放, 也就是单个请求处理完成之后释放, 而persistent_list在php_module_shutdown()的时候调用zend_shutdown()释放, 也就是在整个进程完成执行时释放

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download
The most popular open source editor
