如何让Symfony2设置MySQL time_zone?

Ces*_*sar 2 php mysql timezone symfony doctrine-orm

如何在Symfony2中设置自定义驱动程序选项?

在这种情况下,我想SET time_zone = '-04:30'在MySQL中运行作为连接初始化的一部分.

Ces*_*sar 5

设置app/config/config.yml如下:

doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8
        # Here we configure the custom driver options
        # In this case is PDO::MYSQL_ATTR_INIT_COMMAND
        # The constant can not be used in this context
        options: {1002: "SET time_zone = '-04:30'"}
Run Code Online (Sandbox Code Playgroud)