php-mysql扩展的mysql_connect/mysql_pconnect比较
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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.
