Home > Backend Development > PHP Tutorial > Solution to the problem that mysql database connection resources cannot be released in the CI framework, cimysql_PHP tutorial

Solution to the problem that mysql database connection resources cannot be released in the CI framework, cimysql_PHP tutorial

WBOY
Release: 2016-07-12 08:52:10
Original
713 people have browsed it

The solution to the problem that mysql database connection resources cannot be released in the CI framework. cimysql

This article analyzes the solution to the problem that the mysql database connection resources cannot be released in the CI framework. Share it with everyone for your reference, the details are as follows:

Query data using the classes provided by the ci framework:

$this->load->database();
$query = $this->db->query($sql);

Copy after login

After the program runs for a period of time, an error is reported, telling the database that there are too many connections

Obviously the MySQL database connection resources exceed the max_connections setting value. Immediately after each query, add the resource release script:

$this->db->close();

Copy after login
Copy after login

Still unable to release resources, what should I do? After checking the manual, I know, Just set pconnect to false , the settings are roughly as follows:

$db['default']['pconnect'] = FALSE;

Copy after login

After setting, there is no need to call

$this->db->close();

Copy after login
Copy after login

The connection will be automatically closed.

Readers who are interested in more CodeIgniter related content can check out the special topics of this site: "codeigniter introductory tutorial", "CI (CodeIgniter) framework advanced tutorial", "php excellent development framework summary", "ThinkPHP introductory tutorial", "Summary of Common Methods in ThinkPHP", "Introduction Tutorial on Zend FrameWork Framework", "Introduction Tutorial on PHP Object-Oriented Programming", "Introduction Tutorial on PHP MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone’s PHP program design based on the CodeIgniter framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1127872.htmlTechArticleThe solution to the problem that mysql database connection resources cannot be released in the CI framework, cimysql This article analyzes the mysql database connection problem in the CI framework Solution to resource failure to release. Share with everyone...
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