CodeIgniter database connections not being closed CodeIgniter database connections not being closed codeigniter codeigniter

CodeIgniter database connections not being closed


I think that you're gettting problemns with the initial configurations from Codeigniter connection database.

At this page, you can see each value from config array:
https://www.codeigniter.com/user_guide/database/configuration.html

$db['default']['hostname'] = "localhost";$db['default']['username'] = "root";$db['default']['password'] = "";$db['default']['database'] = "database_name";$db['default']['dbdriver'] = "mysql";$db['default']['dbprefix'] = "";$db['default']['pconnect'] = TRUE;$db['default']['db_debug'] = FALSE;$db['default']['cache_on'] = FALSE;$db['default']['cachedir'] = "";$db['default']['char_set'] = "utf8";$db['default']['dbcollat'] = "utf8_general_ci";$db['default']['swap_pre'] = "";$db['default']['autoinit'] = TRUE;$db['default']['stricton'] = FALSE;

This it's an basic array config database, try to set the variable of pconnect to FALSE, when it is turned on, the system doesn't close any connection and it stay opened to news queries at any time.

If you set it to false like i said, your system will continue working perfectly, but the codeigniter will close and open the connection when he need's to use the database.

Here, you can find and post inside codeigniter forum with a guy that's have a problem with pconnect variables, may help you!http://codeigniter.com/forums/viewthread/177573/#842016


Codeigniter should automatically close the database connection but you can implicitly call it with $this->db->close();

See http://codeigniter.com/user_guide/database/connecting.html


have you tried to do $this->db->close(); after a query is made?