Search code examples
doctrine-ormcase-sensitive

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?


Solution

  • 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."