Home>

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

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

After running the program for a while,An error is reported to the database too many connections

Obviously the mysql database connection resource exceeds the max_connections setting. Immediately after each query,Add resource release script:

$this->db-&close;close ();

Still unable to release resources,How to do it?After reviewing the manual,Got it,Just set pconnect to falseThe settings are roughly as follows:

$db ["default"] ["pconnect"]=false;

No need to call after setting

$this->db-&close;close ();

The connection is automatically closed.

php
  • Previous PHP regular expression tutorial (recommended)
  • Next Detailed integration of CI framework smarty steps