protected function findWithCriteria(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
$qb = $this->getLoadQuery();
foreach ($criteria as $col => $val) {
if (is_array($val)) {
$qb->andWhere($this->getAlias() . ".{$col} IN(:{$col})");
$qb->setParameter(":{$col}", $val, Connection::PARAM_INT_ARRAY);
} else {
$qb->andWhere($this->getAlias() . ".{$col} = :{$col}");
$qb->setParameter(":{$col}", $val);
}
}
if ($orderBy) {
$qb->orderBy($orderBy[0], $orderBy[1]);
}
if ($limit) {
$qb->setMaxResults($limit);
}
if ($offset) {
$qb->setFirstResult($offset);
}
return $qb;
}