I would like to know if this is possible in doctrine ORM symfony. I have a list of Products. Each product has a Title. let say their titles are:
1. Great Mango
2. Show Mango
3. King Mango
I use this doctrine to find the title
$repository->findByTitle("Mango");
but I display nothing. If I complete the title to search it like "King Mango". It display but not the list with the MANGO word.
I used this link for reference. but if you have more documentation about this. I'm happy to learn from it.
To use a like in the where clause, you have to use where condition with setParameter.
query as below:
$title = 'Mango';
$query = $repository->createQueryBuilder('a')
->where('a.title LIKE :title')
->setParameter('title', '%'.$title.'%')
->getQuery();
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