Doctrine2 区分大小写的查询 [英] Doctrine2 case-sensitive query
问题描述
出于某种原因,我需要在 MySql + 学说 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();
正在工作.有什么想法吗?
is working. Any idea?
推荐答案
也许您正在使用以_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-sensitive.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屋!