/
Closing database connection when die() in script

Closing database connection when die() in script

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/22da5ee2d56401c5#

One recent project has shown, that having die() executed frequently in code might cause database connection to "freeze", in other words - this "dead" connection does not disconnect and as a result, maximum allowed db connections becomes a cause for other sites, running on same server, to receive "cannot connect to database server - maximum allowed connections exceeded".

Solution

I propose handling database closure process within __destruct() method inside of kDbConnection class, as this method should be executed even if die() is called.