public function paginate(ModelCriteria $query, $page = 1, $maxPerPage = 25) { $queryMd5 = md5($query->toString()); $key = $query->getTableMap()->getName() . '_query_' . $queryMd5 . '_' . $page . '_' . $maxPerPage; $records = GlobalCache::get($key); if (empty($records) === true) { $records = $query->paginate($page, $maxPerPage); if ($records->isEmpty() === false) { GlobalCache::set($key, $records); } } return $records; }
public function testPaginate() { $c = new ModelCriteria('bookstore', 'Propel\\Tests\\Bookstore\\Book', 'b'); $c->join('b.Author a'); $c->where('a.FirstName = ?', 'Neal'); $books = $c->paginate(1, 5); $this->assertTrue($books instanceof PropelModelPager, 'paginate() returns a PropelModelPager'); $this->assertEquals(1, count($books), 'paginate() returns a countable pager with the correct count'); foreach ($books as $book) { $this->assertEquals('Neal', $book->getAuthor()->getFirstName(), 'paginate() returns an iterable pager'); } }
/** * @param ModelCriteria $search * @param PropelModelPager|null $pagination * * @return array|PropelModelPager */ protected function searchWithPagination(ModelCriteria $search, &$pagination) { $page = intval($this->getArgValue('page')); $limit = intval($this->getArgValue('limit')); $pagination = $search->paginate($page, $limit); if ($page > $pagination->getLastPage()) { return []; } else { return $pagination; } }
public function paginate(ModelCriteria $query, $page = 1, $maxPerPage = 25) { return $query->paginate($page, $maxPerPage); }