Doctrine2: How to set all tables to collate with UTF8

前端 未结 14 1032
夕颜
夕颜 2020-12-08 02:55

I am using Doctrine with Symfony2. My config.yml file looks something like this:-

Doctrine Configuration

doctrine:
    dbal:
        driver: %data         


        
14条回答
  •  情歌与酒
    2020-12-08 03:32

    I've got this problems with fetching data which includes polish characters from database. It looks like:

    effects of displaying data from db

    my config.yml is like:

    doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        options:
             1002:  "SET NAMES 'UTF8'"
    

    and I've been searching for an answer for couple of hours - Im so tired of this. "1002: SET NAMES 'utf8'" Doesnt work for me. But when I tryed to access my db from simple php script (out of symfony) the effect was the same but when I added line:

    mysql_query("SET NAMES 'utf8'");
    

    it worked properly. So it seems to be little strange. All the tables in my db have 'utf8_unicode_ci' set.

提交回复
热议问题