Answer the question
In order to leave comments, you need to log in
How to set SQL in the config, which is filled after the creation of the DbConnection?
Hello!
I'm running php workers. For them, after connecting to the database, you need to run
SET wait_timeout = 259200;
SET interactive_timeout = 259200;
Answer the question
In order to leave comments, you need to log in
Good afternoon. Try this: there are several triggers in yii\db\Connection, you definitely need to hook on EVENT_AFTER_OPEN.
Something along the lines of:
...
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=mydb',
'username' => 'myname',
'password' => 'mypassword',
'charset' => 'utf8',
'on ' . yii\db\Connection::EVENT_AFTER_OPEN => function () {
Yii::$app->db->createCommand("SET wait_timeout = 259200")->execute();
Yii::$app->db->createCommand("SET interactive_timeout = 259200")->execute();
},
]
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question