3

I can't find documentation about Yii2 persistent connection.

I have problems with Yii2 behavior. It always opens the connection and closes it after executing the query. I think creating a persistent connection is the answer to my problems.

How to do that?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
rico
  • 63
  • 1
  • 7

1 Answers1

3

See the following github issue:

    'db' => array(
        'class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost;dbname=dbname',
        'username' => 'root',
        'password' => '',
        'tablePrefix' => '',
        'charset' => 'utf8',
        'attributes'=>[
            PDO::ATTR_PERSISTENT => true
        ]
    ),
deacs
  • 4,259
  • 2
  • 27
  • 37