Child pages
  • Closing database connection when die() in script
Skip to end of metadata
Go to start of metadata

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.

2 Comments

  1. Hi Nikita,

    Thanks for reporting. Let's start with looking at your specific project
    needs since have justed tested a simple test on my end and MySQL Connections
    were closed as soon as script ended (with die).

    Please email me directly so we can take a closer look at this.

    Thanks.

    DA

  2. I believe this might be a server issue (PHP4) since we have unsuccessfully
    tried replicating this on another copy.

    DA