Browse Source

Fixes #1522: added example of executing extra queries right after establishing DB connection

tags/2.0.0-beta
Alexander Makarov 11 years ago
parent
commit
12e6c9bc29
  1. 20
      docs/guide/database-basics.md

20
docs/guide/database-basics.md

@ -72,6 +72,26 @@ $connection->open();
``` ```
> **Tip**: if you need to execute additional SQL queries right after establishing a connection you can add the
> following to your application configuration file:
>
```php
return [
// ...
'components' => [
// ...
'db' => [
'class' => 'yii\db\Connection',
// ...
'on afterOpen' => function($event) {
$event->sender->createCommand("SET time_zone = 'UTC'")->execute();
}
],
],
// ...
];
```
Basic SQL queries Basic SQL queries
----------------- -----------------

Loading…
Cancel
Save