Reputation: 393
I am using symfony3 and I was wondering whether it is possible to search with doctrine and use a an array as parameters. here is my code:
foreach($statesData as $val){
$dataState[] = array('id' => $val->getId());
}
$cities=$em->getRepository('AppBundle:Cities')->findByStateId($dataState);
I basically want the equivalent to 'LIKE' mysql expression
Upvotes: 1
Views: 207
Reputation: 301075
Sounds like you want IN
rather than LIKE
- you can use the query builder to do that - something like this...
$cities=$em->getRepository('AppBundle:Cities');
$qb=$cities->createQueryBuilder('c');
$qb->where($qb->expr()->in('c.stateId', $dataState));
$query=$qb->query();
$result=$query->getResult();
Upvotes: 1