本文整理匯總了PHP中Propel\Runtime\ActiveQuery\ModelCriteria::paginate方法的典型用法代碼示例。如果您正苦於以下問題:PHP ModelCriteria::paginate方法的具體用法?PHP ModelCriteria::paginate怎麽用?PHP ModelCriteria::paginate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Propel\Runtime\ActiveQuery\ModelCriteria
的用法示例。
在下文中一共展示了ModelCriteria::paginate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: paginate
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;
}
示例2: testPaginate
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');
}
}
示例3: searchWithPagination
/**
* @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;
}
}
示例4: paginate
public function paginate(ModelCriteria $query, $page = 1, $maxPerPage = 25)
{
return $query->paginate($page, $maxPerPage);
}