php – CodeIgniter opens many database connections


I have an application on the client and they are complaining that it is opening too many connections to the database, causing the server to crash.

I searched the internet and didn't find anything related.

I would like to know if CodeIgniter automatically closes the connection with the bank when it is made or if there is something to close.

I'm new to CodeIgniter and the application was already done when I entered here. She is using Active Record to make the queries .


In application/config/database.php , check that the setting $db['default']['pconnect'] = TRUE; put FALSE , because with TRUE the connection is persistent.

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = 'senha';
$db['default']['database'] = 'testdb';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE; // Coloque FALSE
$db['default']['db_debug'] = TRUE;
$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;

Note: It is the only setting that has this profile to leave the connection open

Scroll to Top