How to define the use of utf-8 in Doctrine 2 in Zend Framework application.ini, when using Bisna

前端 未结 8 1719
暖寄归人
暖寄归人 2020-12-28 08:22

The following ZendCasts cast, shows a way to use doctrine 2 in a zend framework environment.
Using this configuration, how can I make the connection use a utf-8 charset

8条回答
  •  庸人自扰
    2020-12-28 08:30

    It is possible to add it via application.ini, provided you use ZendX_Doctrine2 (at https://github.com/mridgway/ZendX_Doctrine2) with MySQL.

    Then here's the line you need in application.ini:

    resources.entitymanagerfactory.connectionOptions.driverOptions.1002 = "SET NAMES utf8"
    

    (1002 == PDO::MYSQL_ATTR_INIT_COMMAND)

    Don't forget to correctly set

    default-character-set=utf8
    

    in your my.cnf

提交回复
热议问题