Applies LIMIT and OFFSET to the specified query criteria.
@param CDbCriteria $criteria the query criteria that should be applied with the limit
519641
public function applyLimit($criteria)
	{
		$criteria->limit=$this->getLimit();
		$criteria->offset=$this->getOffset();
	}
100615
public function parse(array $criteria, array $orderBy = array(), $limit = null, $offset = null)
    {
        $statement = new Expr\Statement();

        if(!empty($criteria)) {
            $statement->setClause('condition', $this->parseCriteria($criteria));
        }

        if(!empty($orderBy)) 
            $statement->setClause('order', $this->parseOrderBy($orderBy));
        if($limit)
            $statement->setClause('limit', $this->parseLimit($limit));
        if($offset)
            $statement->setClause('offset', $this->parseOffset($offset));

        return new Query($statement, $this->persister);
    }
147726
protected function applySubtreeLimitation(DatabaseQuery $query, $rootLocationId)
    {
        $query->where(
            $query->expr->like(
                $this->handler->quoteColumn('path_string', 'ezcontentobject_tree'),
                $query->bindValue('%/' . $rootLocationId . '/%')
            )
        );
    }
661193
protected function applyLimitConditions(ISelectBuilder $selectBuilder)
    {
        if ($this->limit) {
            $postfix = self::PLACEHOLDER_SEPARATOR . $this->collection->getName();

            $limitPlaceholder = ':limit' . $postfix;
            $offsetPlaceholder = ':offset' . $postfix;

            $selectBuilder
                ->limit($limitPlaceholder)
                ->bindInt($limitPlaceholder, $this->limit);
            if ($this->offset) {
                $selectBuilder
                    ->offset($offsetPlaceholder)
                    ->bindInt($offsetPlaceholder, $this->offset);
            }
        }
    }
1028063
protected function validate_criteria($criteria) {
        $criteria = strtoupper($criteria);

        if(in_array($criteria, $this->available_criteria) === false) {
            throw new InvalidWhereQueryCriteriaException();
        }

        return $criteria;
    }
10334
protected function processPagination(array $pagination, Criteria $criteria): void
    {
        if (isset($pagination['offset'])) {
            $criteria->setFirstResult((int) $pagination['offset']);
        }

        if (isset($pagination['limit'])) {
            $criteria->setMaxResults((int) $pagination['limit']);
        }
    }
457655
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $this->throwBadMethodException('findBy');
    }
1174886
protected function getQueryCount(ICriteria $criteria) {

		$queryBuilder = $this->getEntityManager()->createQueryBuilder();
		
		// delegamos a cada dao espec�fico la creaci�n del query builder.
		$queryBuilder = $this->getQueryCountBuilder($criteria);

		$this->enhanceQueryBuild($queryBuilder, $criteria);
		
		//obtenemos el query del builder.
		return $queryBuilder->getQuery();
	}
26228
public function apply($builder, QueryInterface $query): void
    {
        // Apply joins
        foreach ($query->getJoins() as $join) {
            if ($join->isInner()) {
                $builder->innerJoin($join->getFromAlias(), $join->getTo(), $join->getToAlias(), $join->getCondition());
            } else {
                $builder->leftJoin($join->getFromAlias(), $join->getTo(), $join->getToAlias(), $join->getCondition());
            }
        }

        // Apply rules
        foreach ($query->getRules() as $rule) {
            $builder->andWhere($rule->getRule());
        }

        // Apply parameters
        foreach ($query->getParameters() as $parameter) {
            $builder->setParameter($parameter->getName(), $parameter->getValue(), $parameter->getType());
        }

        // Apply orders
        foreach ($query->getOrders() as $order) {
            $builder->addOrderBy($order->getField(), $order->getDirection());
        }
    }
1032397
public function limit($offset, $limit)
	{
		$this->criteria->setFirstResult($offset)->setMaxResults($limit);

		return $this;
	}
821144
public function addSearchCriteria(array $criteria)
    {
        $suffix = $this->getSuffix();
        foreach ($criteria as $crit => $value) {
            if (false === strpos($crit, '.')) {
                $crit = (true === in_array($crit, self::$joinCriteria) ? $this->getSectionAlias() : $this->getAlias()).'.'.$crit;
            }

            $param = str_replace('.', '_', $crit).$suffix;
            $this->andWhere($crit.' IN (:'.$param.')')
                    ->setParameter($param, $value);
        }

        return $this;
    }
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;
    }
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;
    }
435836
public function countByCriteria(Criteria $criteria)
    {
        $qb = $this->createCriteriaQueryBuilder($criteria, 'm');

        $qb->select('COUNT(m.id)');

        return $qb->getQuery()->getSingleScalarResult();
    }
479812
protected function set_limit($query, $limit = 0, $offset = 0)
    {
        $limit  = intval($limit);
        $offset = intval($offset);
        $end    = $offset + $limit;

        // @TODO: Oracle 12g has better OFFSET support

        if (!$offset) {
            $query = "SELECT * FROM ($query) a WHERE rownum <= $end";
        }
        else {
            $query = "SELECT * FROM (SELECT a.*, rownum as rn FROM ($query) a WHERE rownum <= $end) b WHERE rn > $offset";
        }

        return $query;
    }
1319702
public function count($criteria)
	{
		Yii::trace(get_class($this->_joinTree->model).'.count() eagerly','system.db.ar.CActiveRecord');
		$this->joinAll=$criteria->together!==true;

		$alias=$criteria->alias===null ? 't' : $criteria->alias;
		$this->_joinTree->tableAlias=$alias;
		$this->_joinTree->rawTableAlias=$this->_builder->getSchema()->quoteTableName($alias);

		$n=$this->_joinTree->count($criteria);
		$this->destroyJoinTree();
		return $n;
	}
366476
public function init(BaseModelCriteria $criteria, DataFetcherInterface $dataFetcher = null)
    {
        $this->dbName = $criteria->getDbName();
        $this->setClass($criteria->getModelName());
        $this->setWith($criteria->getWith());
        $this->asColumns = $criteria->getAsColumns();
        $this->hasLimit = $criteria->getLimit() != -1;
        if ($dataFetcher) {
            $this->setDataFetcher($dataFetcher);
        }

        return $this;
    }