public function buildLimit(Fetcher $fetcher) { if (!$fetcher->hasLimit()) { return ''; } else { $offset = ($fetcher->getPage() - 1) * $fetcher->getNbByPage(); $sql = sprintf(" LIMIT %s OFFSET %s", $fetcher->getNbByPage(), $offset); return $sql; } }
public function buildLimit(Fetcher $fetcher) { $offset = null; $limit = null; if ($fetcher->hasLimit()) { $offset = ($fetcher->getPage() - 1) * $fetcher->getNbByPage(); $limit = $fetcher->getNbByPage(); } return array('offset' => $offset, 'limit' => $limit); }
private function reloadResults() { if ($this->lastId !== null) { if ($this->filterIdOperation === null) { $this->filterIdOperation = $this->fetcher->filterByGreaterThanId($this->lastId); } else { $this->filterIdOperation->setValue($this->lastId); } } $this->results = $this->fetchable->getByFetcher($this->fetcher)->getResultSet(); if (!$this->fetcher->hasResults()) { $this->ended = true; $this->currentKey = null; } else { if ($this->fetcher->count() !== $this->fetcher->getNbByPage()) { $this->ended = true; } $this->currentKey = key($this->results); /** @var VO $vo */ $vo = current($this->results); if ($vo !== false) { $this->lastId = $vo->getId(); } } }