Codeigniter opens many connections to the database

Asked

Viewed 1,244 times

3

I have an application on the client and they are complaining that it is opening many connections with the database, dropping the server.

I searched the Internet and couldn’t find anything related.

I wonder if Codeigniter automatically closes the connection to the bank when it is held or if it has something to close.

I’m new to Codeigniter and the application was already done when I came in here. It’s using Active Record to make the darlings.

  • Did you get any response Ligdark???

1 answer

1

In application/config/database.php, check if the configuration $db['default']['pconnect'] = TRUE; place FALSE, because, with TRUE the connection stays 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;

Obs: It is the only configuration that has this profile to leave the connection open

  • 1

    I sent the solution to the customer , and I haven’t gotten back yet, but I think it worked. Valeu mano.

  • Something News @Ligdark

  • Dude, I think it worked, I didn’t get a negative customer feedback... obg :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.