Doctrine2与Symfony2不识别db字符集和整理 [英] Doctrine2 with Symfony2 not recognizing db charset and collation

查看:149
本文介绍了Doctrine2与Symfony2不识别db字符集和整理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图让Doctrine2在Debian挤压系统上使用Symfony2中的mysql数据库正常工作。
DB的字符集和排序规则设置为utf8和utf8_general_ci,并通过读取sql脚本手动创建数据库。

I am trying to get Doctrine2 to work properly with a mysql db in Symfony2 on a debian squeeze system. The charset and collation of the DB are set to utf8 and utf8_general_ci and the db is created manually by reading in an sql script.

现在我输入一些值对于其中一个表与丹麦特殊字符像æøå,他们只是无法正确显示。

Now I enter some values for one of the tables with danish special chars like æøå and they simply wont display correctly.

我的parameters.yml已设置encoding:utf8和在我的config.yml的教义配置有:

My parameters.yml has set encoding: utf8 and in my config.yml the doctrine configuration has:

doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

当我在mysql控制台中进行选择时,字符显示正确,如果我尝试通过将输出数组替换控制器通过som硬编码的值,所以问题似乎肯定是源于某种错误/错误在doctrine2配置有没有任何线索可以解决这个问题?

When I do a select in the mysql console, the characters display correctly and also if I try by replacing the output array in the controller by som hardcoded values, so the problem seems definately to stem from some kind of error/bug in doctrine2 configuration...

非常感谢。

/ p>

Thanks a lot.

推荐答案

好的,我终于弄清楚了...这种配置有一些双重编码。注释字符集:来自doctrine dbal config的UTF8解决问题。

Ok I finally figured it out... there is some kind of double encoding going on with this configuration. Commenting out charset: UTF8 from doctrine dbal config solves the problem.

这篇关于Doctrine2与Symfony2不识别db字符集和整理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆