How to set database time zone in application.ini

前端 未结 4 2036
一生所求
一生所求 2021-02-04 02:20

I have an application in Zend Framework that has to run for a different time zone than the server. Is there an option to set the database server (MySQL in this case) time zone i

相关标签:
4条回答
  • 2021-02-04 02:36

    you might as well consider adding it on your bootstrap:

    <?php 
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
        protected function _initTimeZone() {
            date_default_timezone_set('Asia/Manila');
        }
    }
    
    0 讨论(0)
  • 2021-02-04 02:46

    Try build pre dispatch plugin and get data from config file for query

    0 讨论(0)
  • 2021-02-04 02:52

    I'm answering my own question just to close this, as the response is already in one of the edits.

    resources.db.params.charset
    

    and

    resources.db.params.driver_options.1002
    

    as I had in my application.ini cannot be used together, as resources.db.params.charset ovewirites driver_options.1002.

    If you need to set the timezone, remove resources.db.params.charset and pass the timezone in the charset in driver_options. E.g.:

    resources.db.params.driver_options.1002 = "SET NAMES utf8, time_zone = 'Europe/London'"
    
    0 讨论(0)
  • 2021-02-04 02:52

    This works for me:

    resources.db.adapter = "Pdo_Mysql"
    resources.db.params.driver_options.1002 = "SET NAMES 'utf8', CHARACTER SET 'utf8', time_zone = 'Europe/London'"
    
    0 讨论(0)
提交回复
热议问题