-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDO exception when loading test fixtures and using Mysql init commands #8017
Comments
Not sure if there is a way to solve this. Sounds like it is a problem with PDO rather than Yii. |
You could run those extra queries another way: 'db' => [
'class' => 'yii\db\Connection',
'charset' => 'utf8',
'on '.\yii\db\Connection::EVENT_AFTER_OPEN => function () {
Yii::$app->db->createCommand('SET SESSION sql_mode = \'STRICT_TRANS_TABLES\'')->execute();
Yii::$app->db->createCommand('SET SESSION time_zone = \'+0:00\'')->execute();
},
], |
After a quick google I found a related SO question. Maybe you can't execute more than one query this way, try setting both values in a single |
Yes, you are correct, this is due to https://bugs.php.net/bug.php?id=48859 'db' => [
'class' => 'yii\db\Connection',
'charset' => 'utf8',
'attributes' => [
PDO::MYSQL_ATTR_INIT_COMMAND => '
SET SESSION sql_mode = \'STRICT_TRANS_TABLES\', time_zone = \'+0:00\';
'
]
], Thanks for your help and sorry for the confusion. |
@cebe maybe it's worth adding example usage for |
Isn't |
Both solutions are be correct but using |
Relates #3695 |
Hi |
hii |
Hello, I am facing the same problem.. any update on this?? |
I have added an example to the guide: a1066c5 |
Is there any way to import database(sql file) using query ?? |
I am getting following error while importing.. |
see here: #3695 (comment) |
when I tried it show me setAttribute is not defined. |
you have to call |
Ok.. I called it. Now it give PDO class not found.. |
most probably because you are in a namespace, add a backslash before it: |
Yes, it resolved PDO class error.. Thanks. |
One issue per one problem. |
I have run into a strange issue. When I add more than one
PDO::MYSQL_ATTR_INIT_COMMAND
commands in my configuration, like this:Then I get the following error when running codeception functional tests that try to load global fixtures.
Any idea what could be using the problem? The issue only happens on Codeship CI server and with any two commands in the configuration. When I remove any one, the issue dissapears.
Setting
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
to true did not help. Also settingemulatePrepare
to true did not help.Thanks!
The text was updated successfully, but these errors were encountered: