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.

Does Phalcon supports persistent DB connection?

Hi. My question is about connection pooling.

Does Phalcon natively supports DB connection pooling? Or: Can I create persistent DB connection like in mysql: mysql_pconect() (or with "p:" prefix in hostname)?

edited Oct '14

You can make phalcon to create persistent DB connections when setting up the DB service with settings array like this:


username        = myuser
password        = mypassword
dbname          = mydb
host            =
persistent      = true
encoding        = UTF8


  $config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config.ini');


    //Set the database service
    $di->set('db', function() use ($config){
        return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
            "host"      => $config->database->host,
            "username"  => $config->database->username,
            "password"  => $config->database->password,
            "dbname"    => $config->database->dbname,
            "charset"   => $config->database->encoding,
            "persistent"=> $config->database->persistent


Thank you! I did not find it in the API docs...


Yeah, I need to re-read docs now... I read full docs for Phalcon a year ago, after - only changelogs :)