I want to add orWhere conditions to query builder. params will come from array. but I dont know how I can add count of orWhere statements equal to count array elements. Here is some code:
public function selectRelatedTrips($assoc)
{
$params = array('k' => 'Kiev');
$query = $this
->getEntityManager()
->createQueryBuilder()
->select('t')
->from('VputiTripBundle:Trip', 't')
->where('t.startCity = :k');
foreach ($assoc as $k => $v) {
// $query->orWhere('t.startCity = ' . $v);
$query->where('t.startCity = :param' . $k);
$params['param' . $k] = $v;
}
return $query->setParameters($params)
->setMaxResults(20)
->orderBy('t.id', 'desc')
->getQuery()
->getResult();
}
Can somebody help me please?