CodeIgniter Forums
Database connection flood - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Database connection flood (/showthread.php?tid=48856)



Database connection flood - El Forum - 01-31-2012

[eluser]Ku Yu Cheung[/eluser]
Hello, i'm experiencing problems with my code:

each time that the application's homepage is loaded, a new (fresh) database connection is created and it stays open.

If there are many open connections, the application can be slow in responding or can stop working. this issue happens only on the production server, and i think that is a mysql issue. I see that the db assigns a new port for each new connection created. Can CI be forced to use always the same connection?


Database connection flood - El Forum - 01-31-2012

[eluser]Bhashkar Yadav[/eluser]
can you please check by updating as FALSE to $db['default']['autoinit'] into application/config/database.php.


Database connection flood - El Forum - 01-31-2012

[eluser]Ku Yu Cheung[/eluser]
just updated the configuration, nothing has changed Sad


Database connection flood - El Forum - 01-31-2012

[eluser]Ku Yu Cheung[/eluser]
Perhaps CI leaves some db connection open after the scripts are finished?


Database connection flood - El Forum - 01-31-2012

[eluser]CroNiX[/eluser]
No, CI terminates the connection at the very end of /system/core/CodeIgniter.php.

Try disabling the Persistent Connections: $db['default']['pconnect'] = FALSE;


Database connection flood - El Forum - 01-31-2012

[eluser]Ku Yu Cheung[/eluser]
thank you, this solved my issue Smile Smile


Database connection flood - El Forum - 01-31-2012

[eluser]InsiteFX[/eluser]
Things to try!
Code:
// port - The database port number. To use this value you have to add a line to the database config array.
$db['default']['port'] = 5432;

// also try this
$this->db->close();

pconnect causes problems do not use it!



Database connection flood - El Forum - 01-31-2012

[eluser]Bhashkar Yadav[/eluser]
@InsiteFX : Thanks a lot, i was also digging into it but couldn't notice persistence database connection setting ...