本文整理汇总了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);
}