Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine2 case-sensitive query

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

neither

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

nor

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

is working. Any idea?

like image 564
user1592714 Avatar asked Aug 26 '12 11:08

user1592714


1 Answers

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.

See http://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html

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

like image 73
Leif Avatar answered Oct 04 '22 21:10

Leif