示例#1
0
 public function testPaginate()
 {
     $c = new ModelCriteria('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');
     }
 }
示例#2
0
 /**
  * Paginate collection.
  *
  * @param int $page
  * @param int $numPerPage
  * @return mixed
  */
 public function paginate($page, $numPerPage)
 {
     return $this->query->paginate($page, $numPerPage);
 }
示例#3
0
 /**
  * @inheritDoc
  */
 public function paginate()
 {
     $this->query->paginate($this->page, $this->limit);
     return $this->query;
 }
示例#4
0
 protected function find(\ModelCriteria $query, $params)
 {
     $page = isset($params['p']) ? $params['p'] : 1;
     $maxPerPage = isset($params['mpp']) ? $params['mpp'] : $this->options['maxPerPage'];
     $pager = $query->paginate($page, $maxPerPage);
     return $pager;
 }