In this paper, we analyze the solution to the failure of the MySQL database connection resource to be released in CI framework. Share to everyone for your reference, specific as follows:
Use the CI framework to provide class query data:
$this->load->database ();
$query = $this->db->query ($sql);
After the program runs for a period of time, the error, inform the database too many connections
It is obvious that the MySQL database connection resource exceeds the Max_connections set value. Immediately after each query, add the resource release script:
Still unable to release resources, how to do? After viewing the manual, you know, as long as the pconnect set to false on it , set roughly as follows:
$db [' Default '] [' pconnect '] = FALSE;
After setting, you do not need to call
You can automatically close the connection.
More interested in CodeIgniter related content readers can view the site topics: "CodeIgniter Introductory Course", "CI (CodeIgniter) Framework Advanced Course", "PHP Excellent Development Framework Summary", "thinkphp Introductory Course", " Thinkphp Common Methods Summary, "Zend Framework Introduction Course", "PHP object-oriented Programming Introduction Course", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on CodeIgniter framework.