Skip to content

Commit

Permalink
Merge pull request #26 from AppsDevTeam/query-object-fetch-support-of…
Browse files Browse the repository at this point in the history
…fset

QueryObject::fetch - support offset
  • Loading branch information
thorewi authored Aug 30, 2023
2 parents 7cac3be + 2094711 commit 689da8a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/QueryObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private function isAlreadyJoined(string $filterKey): bool
* @throws ReflectionException
* @throws Exception
*/
final public function fetch(?int $limit = null): array
final public function fetch(?int $limit = null, ?int $offset = null): array
{
$qb = $this->createQueryBuilder();

Expand All @@ -413,6 +413,10 @@ final public function fetch(?int $limit = null): array
$query->setMaxResults($limit);
}

if ($offset) {
$query->setFirstResult($offset);
}

$result = $query->getResult();

$this->postFetch(new ArrayIterator($result));
Expand Down

0 comments on commit 689da8a

Please sign in to comment.