如何使用doctrine2将表排序规则设置为utf_general_ci [英] How to set the table collation to utf_general_ci using doctrine2

查看:131
本文介绍了如何使用doctrine2将表排序规则设置为utf_general_ci的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,在使用doctrine2的应用程序中出现以下错误

Today I got the following error in an application which uses doctrine2

Message: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_unicode_ci,COERCIBLE) for operation 'like' 

I

在我的应用程序中,我将原则配置为使用utf8

Within my application I configured doctrine to use utf8

$em->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')); 

我的数据库是通过安装脚本生成的,并向其配置了相等的实体管理器。

My database was generated via install script threw an equal configured entity manager.

如何使用doctrine2将表的排序规则设置为utf8_general_ci?

How to set my table's collation to utf8_general_ci using doctrine2?

推荐答案

以前,我在 Symfony ,后来移至学说。 @ elliot 提到了创建数据库中的问题

Previously I reported a Bug in Symfony and later moved to Doctrine. @elliot mentioned the problem in create database.

因此在这种情况下,我认为该错误仍然存​​在。因此,您想使用utf-8手动创建数据库,然后它将完成其他工作。

So in this case I guess the bug is still there. So you want to create the database manually with utf-8, then it will do the other work.

但是根据Benjamin Eberlei的说法,他提到了 postConnect 事件监听器适用于调用 SET NAMES UTF-8的MySQL。他提到的DBAL链接已损坏,否则我会调查一下。

But according to Benjamin Eberlei he mentions about postConnect event listener for MySQL which calls 'SET NAMES UTF-8'. The DBAL link he mentioned was broken, else I would have looked into it.

希望这会有所帮助

这篇关于如何使用doctrine2将表排序规则设置为utf_general_ci的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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