@param SearchCriteria $criteria
@param int|null       $limit
@param int            $offset

@return SearchResults
964700
public function search(SearchCriteria $criteria, $limit = null, $offset = 0)
    {
        $actor = $criteria->actor;

        $query = $this->pages->query();

        if ($actor !== null && !$actor->isAdmin()) {
            $query->whereIsHidden(0);
        }

        $search = new PageSearch($query->getQuery(), $actor);

        $this->gambits->apply($search, $criteria->query);
        $this->applySort($search, $criteria->sort);
        $this->applyOffset($search, $offset);
        $this->applyLimit($search, $limit + 1);

        $pages = $query->get();

        if ($areMoreResults = ($limit > 0 && $pages->count() > $limit)) {
            $pages->pop();
        }

        return new SearchResults($pages, $areMoreResults);
    }
1107907
protected function queryLimitOffset($query, $limit = null, $offset = 0)
    {
        $limit  = $limit ?: $this->limit;
        $offset = $offset ?: $this->offset;

        if ($limit) {
            $query->take($limit)->skip($offset);
        }

        return $query;
    }
619917
private function getSearchQueryLimit($query, $limit, $offset)
	{
		if ($limit > -1) {
			$query->limit($limit);
			$query->offset($offset);
		}

		return $query;
	}
30567
public function loadAll(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null)
    {
        $pool       = $this->manager->getPool();
        $manager_id = $this->class->getManagerIdentifier();

        $models = array();
        foreach ($this->class->getFieldManagerNames() as $manager) {
            $models[$manager] = $this->class->getFieldMapping($manager)->getName();
        }

        $data = $pool->getManager($manager_id)->getRepository($models[$manager_id])->findBy($criteria, $orderBy, $limit, $offset);

        if (empty($data)) {
            return array();
        }

        $builder = new ModelBuilder($this->manager, $this->uow, $this->class);

        return $builder->buildAll($data, $manager_id);
    }
457655
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $this->throwBadMethodException('findBy');
    }
380788
public function loadAll(array $criteria = [], $limit = null)
    {
        $qb = $this->dm->createQueryBuilder($this->class->name)->addCriteria($criteria);

        return $qb->getQuery()->limit($limit)->execute();
    }
595640
public function filterBy(array $criteria, array $orderBy = null, $limit = null, $offset = null, CompositeExpression $externalExpression = null)
    {
        $qb = $this->repository->createQueryBuilder('user')->distinct(true)
            ->leftJoin('user.contact', 'contact')
            ->leftJoin('contact.addresses', 'address')
            ->andWhere('address.type = :addressType')
            ->setParameter('addressType', 'main');

        if (array_key_exists('search', $criteria)) {
            $qb->andWhere('user.username like :searchLike or address.firstName like :searchLike or address.lastName like :searchLike or user.id=:search');
            $qb->setParameter('search', $criteria['search']);
            $qb->setParameter('searchLike', '%'.$criteria['search'].'%');
        }

        if (is_array($orderBy)) {
            foreach ($orderBy as $key => $value) {
                if ($key === 'id') {
                    $key = 'user.id';
                }
                $qb->orderBy($key, $value);
            }
        }

        $query = $qb->getQuery();
        $arrayResult = $query->getResult();
        $count = count($arrayResult);

        if ($offset === null) {
            $offset = 0;
        }

        if ($offset || $limit) {
            $arrayResult = array_slice($arrayResult, $offset, $limit);
        }

        $result = new FilterResult($arrayResult);
        $result->setCount($count);

        return $result;
    }
268339
public function loadAll(array $criteria = [], ?array $sort = null, ?int $limit = null, ?int $skip = null) : Iterator
    {
        $criteria = $this->prepareQueryOrNewObj($criteria);
        $criteria = $this->addDiscriminatorToPreparedQuery($criteria);
        $criteria = $this->addFilterToPreparedQuery($criteria);

        $options = [];
        if ($sort !== null) {
            $options['sort'] = $this->prepareSort($sort);
        }

        if ($limit !== null) {
            $options['limit'] = $limit;
        }

        if ($skip !== null) {
            $options['skip'] = $skip;
        }

        assert($this->collection instanceof Collection);
        $baseCursor = $this->collection->find($criteria, $options);
        return $this->wrapCursor($baseCursor);
    }
1266637
public function find($criteria, $field = null, $limit = null)
    {
        if (is_array($criteria)) {
            return $this->findIn($criteria, $field);
        }

        $field = isset($field) ? $field : $this->primaryKey;
        if (strpos($field, '.') === false) {
            $field = $this->table . '.' . $field;
        }

        if ($result = $this->qb
            ->from($this->table)
            ->where($field, $criteria)
            ->get($limit)) {
            if ($result->count() > 0) {
                $this->result = new DataObjects\Result($result, $this);
                $this->result->setInfo($result->getInfo());

                if ($this->result->count() == 1) {
                    return $this->result->first();
                }

                return $this->result;
            }
        }

        return false;
    }
1083424
public function findAll($limit = 0, $offset = 0)
    {
        $limit = $this->getLimit($limit, $offset);
        $query = 'SELECT ' . $this->getFields(", ") . '
                  FROM ' . $this->tableName . '
                  ' . $limit . ' ;';
        $statement = $this->database->prepare($query);
        $statement->execute();
        return $this->buildAll($statement->fetchAll());
    }
1211847
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        // Check if we have to filter or sort by an encrypted field
        if ($this->filterHasEncryptedField($criteria) || $this->orderByHasEncryptedField($orderBy)) {
            return $this->filterAndSortByEncryptedField($criteria, $orderBy, $limit, $offset);
        }
        else {
            // We can use the usual repository logic
            $entities = $this->wrapped->findBy($criteria, $orderBy, $limit, $offset);
            return $entities;
        }
    }
1174829
public static function query( ezpContentCriteria $criteria )
    {
        $fetchParams = self::translateFetchParams( $criteria );
        $nodes = eZContentObjectTreeNode::subTreeByNodeID( $fetchParams->params, $fetchParams->rootNodeId );
        $return = array();
        foreach( $nodes as $node )
        {
            $return[] = ezpContent::fromNode( $node );
        }
        return $return;
    }
701291
public function createQueryBuilder(array $criteria = null, array $orderBy = null, $limit = null, $offset = null, $class = null)
    {
        $baseQueryBuilder = $this->createBaseQueryBuilder($class);

        $queryBuilder = $this->alterBaseQueryBuilder($baseQueryBuilder);

        if (!is_null($criteria)) {
            foreach ($criteria as $key => $value) {
                $queryBuilder->andWhere($queryBuilder->getRootAliases()[0] . '.' . $key . ' = ' . $this->addNamedParameter($key, $value, $queryBuilder));
            }
        }

        if (!is_null($orderBy)) {
            foreach ($orderBy as $sort => $order) {
                $queryBuilder->addOrderBy($queryBuilder->getRootAliases()[0] . '.' . $sort, $order);
            }
        }

        if (!is_null($limit)) {
            $queryBuilder->setMaxResults($limit);
        }

        if (!is_null($offset)) {
            $queryBuilder->setFirstResult($offset);
        }

        return $queryBuilder;
    }
164370
public function findBy(array $criteria, ?array $sort = null, $limit = null, $skip = null) : array
    {
        return $this->getDocumentPersister()->loadAll($criteria, $sort, $limit, $skip)->toArray();
    }
521025
protected function getHash($query, $criteria, ?array $orderBy = null, $limit = null, $offset = null)
    {
        [$params] = $criteria instanceof Criteria
            ? $this->persister->expandCriteriaParameters($criteria)
            : $this->persister->expandParameters($criteria);

        return sha1($query . serialize($params) . serialize($orderBy) . $limit . $offset);
    }
985753
public function getItems($offset, $limit)
    {
        $this
            ->paginator
            ->getQuery()
            ->setFirstResult($offset)
            ->setMaxResults($limit)
        ;

        return iterator_to_array($this->paginator->getIterator());
    }
425998
public function limit($limit, $offset = null) {
		$this->_criteria->limit($limit, $offset);
		$this->_limit = (int) $limit;
				
		return $this;
	}