Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to realize Persistent Database Connections in Phalcon Framework?

How to do it? I'm wondering, is it possible?


Pass this config to your DB adapter

$config = array(
    "host"     => "localhost",
    "username" => "username",
    "password" => "password",
    "dbname"   => "db_name",
    "persistent" => true

For MySQL, you'd need to set it via 'options' PDO array.

   $dbConfig['options'] = [
        PDO::ATTR_PERSISTENT => 1,
        // Many web applications will benefit from making persistent connections to database servers. Persistent connections are not closed at the end of the script,
        // but are cached and re-used when another script requests a connection using the same credentials.
        // The persistent connection cache allows you to avoid the overhead of establishing a new connection every time a script needs to talk to a database, resulting in a faster web application.

Warning: PDO::__construct(): MySQL server has gone away in

It makes me sad and I can't find an unambiguous decision for mysql innodb.

edited May '16

Try to tune up MySQL timeouts, especially wait_timeout