How to solve the problem that mysql database connection resources cannot be released in the CI framework

不言
Release: 2023-04-01 14:46:01
Original
1510 people have browsed it

This article mainly introduces the solution to the problem that mysql database connection resources cannot be released in the CI framework. It analyzes the reasons and corresponding solutions for the connection exceeding the maximum value in the CI framework. It involves related configuration skills of the CI framework. Friends who need it can Refer to the following

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

Use the class provided by the ci framework to query data:

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

After the program runs for a period of time, An error is reported, informing the database of too many connections

It is obvious that the MySQL database connection resources exceed the max_connections setting value. Immediately after each query, add a resource release script:

$this->db->close();
Copy after login
Copy after login

Still cannot 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, the connection can be automatically closed without calling

$this->db->close();
Copy after login
Copy after login

.

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to solve the 404 error in Nginx and CI framework

About php and codeigniter using session-cookie Method analysis

The above is the detailed content of How to solve the problem that mysql database connection resources cannot be released in the CI framework. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!