Home >Backend Development >PHP Tutorial >How to solve the problem that mysql database connection resources cannot be released in the CI framework
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);
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();
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;
After setting, the connection can be automatically closed without calling
$this->db->close();
.
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!