diff --git a/docs/guide/database-basics.md b/docs/guide/database-basics.md index 520da22..9354a3d 100644 --- a/docs/guide/database-basics.md +++ b/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 -----------------