public function testGetResultsRespectsFormatter()
 {
     $this->createBooks(5);
     $query = BookQuery::create();
     $query->setFormatter(ModelCriteria::FORMAT_ARRAY);
     $pager = new PropelModelPager($query, 4);
     $pager->setPage(1);
     $pager->init();
     $this->assertTrue($pager->getResults() instanceof ArrayCollection, 'getResults() returns a PropelArrayCollection if the query uses array hydration');
 }
 /**
  * Issue a SELECT query based on the current ModelCriteria
  * and uses a page and a maximum number of results per page
  * to compute an offset and a limit.
  *
  * @param int                 $page       number of the page to start the pager on. Page 1 means no offset
  * @param int                 $maxPerPage maximum number of results per page. Determines the limit
  * @param ConnectionInterface $con        an optional connection object
  *
  * @return PropelModelPager a pager object, supporting iteration
  */
 public function paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = null)
 {
     $criteria = $this->isKeepQuery() ? clone $this : $this;
     $pager = new PropelModelPager($criteria, $maxPerPage);
     $pager->setPage($page);
     $pager->init($con);
     return $pager;
 }
Beispiel #3
0
 protected function getPager($maxPerPage, $page = 1)
 {
     $query = QuerycacheTable1Query::create()->setQueryKey('query cache with paginate')->orderByTitle();
     $pager = new PropelModelPager($query, $maxPerPage);
     $pager->setPage($page);
     $pager->init();
     return $pager;
 }