Bolt\Storage\Repository::findWithCriteria PHP Method

findWithCriteria() protected method

Internal method to build a basic select, returns QB object.
protected findWithCriteria ( array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null ) : Doctrine\DBAL\Query\QueryBuilder
$criteria array
$orderBy array
$limit integer
$offset integer
return Doctrine\DBAL\Query\QueryBuilder
    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;
    }