Doctrine2区分大小写的查询 [英] Doctrine2 case-sensitive query

查看:106
本文介绍了Doctrine2区分大小写的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,我需要在MySql + doctrine 2中查询区分大小写。是否可能?

for some reason I need to query 'case-sensitive' in MySql + doctrine 2. Is it possible?

既不是

$em->find('UserEn', 'Bob')

$q = $this->em->createQuery('select u from UserEn u where u.name = :name');
$q->setParameter('name', 'Bob');
$result = $q->getResult();

正在工作。任何想法?

推荐答案

也许您正在使用以_ci结尾的MySQL排序规则,如utf8_general_ci。 ci代表不区分大小写。
如果是这种情况,它不是一个Doctrine问题,而是一个MySQL问题。

Maybe you are using a MySQL collation ending with "_ci", like "utf8_general_ci". "ci" stands for "case insensitive". If this is the case, it is not a Doctrine issue, but a MySQL issue.

请参阅 http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

默认字符集和排序规则为latin1和latin1_swedish_ci,所以非二进制字符串比较默认情况下不区分大小写。

"The default character set and collation are latin1 and latin1_swedish_ci, so nonbinary string comparisons are case insensitive by default."

这篇关于Doctrine2区分大小写的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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