1
0
mirror of synced 2025-02-06 15:29:26 +03:00

Overwrite query limits only if set in QueryBuilder::addCriteria()

This commit is contained in:
Kirill chEbba Chebunin 2012-08-20 16:27:52 +04:00
parent 148789600a
commit d3ab948d88

View File

@ -1024,7 +1024,7 @@ class QueryBuilder
* Add criteria to query. * Add criteria to query.
* Add where expressions with AND operator. * Add where expressions with AND operator.
* Add orderings. * Add orderings.
* Override firstResult and maxResults. * Override firstResult and maxResults if they set.
* *
* @param Criteria $criteria * @param Criteria $criteria
* @return QueryBuilder * @return QueryBuilder
@ -1046,8 +1046,13 @@ class QueryBuilder
} }
} }
$this->setFirstResult($criteria->getFirstResult()); // Overwrite limits only if they was set in criteria
$this->setMaxResults($criteria->getMaxResults()); if (($firstResult = $criteria->getFirstResult()) !== null) {
$this->setFirstResult($firstResult);
}
if (($maxResults = $criteria->getMaxResults()) !== null) {
$this->setMaxResults($maxResults);
}
return $this; return $this;
} }