I have one repository called $colorMaster
$colorMaster->findOneBy(array('name' => 'RED'));
It returns no records even though in my database there is records with Value "Red".
when i try to use same code with value 'Red'
$colorMaster->findOneBy(array('name' => 'Red'));
it returns value.
Is there any way by which we can get case insensitive records from
symfony findOneBy();
so that it can give result using value "RED" also.
Problem is not at Symfony level but at your database level. Some of them are case sensitive and some are not. Yours is case sensitive apparently. To get results, no matter case, try following:
$name = 'REd'; //case doesn't matter
$colorMaster->createQueryBuilder('a')
->where('upper(a.name) = upper(:name)')
->setParameter('name', $name)
->getQuery()
->execute();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With