Exemple #1
0
 /**
  * @return array
  */
 private function getList()
 {
     $return = array();
     $total = 0;
     $pages = 0;
     try {
         $this->paginate();
         if (null !== $this->list) {
             $return = $this->list->toArray();
             $total = $this->list->getNbResults();
             $pages = $this->list->getLastPage();
         }
     } catch (\Exception $e) {
         Logger::getInstance(get_class($this))->errorLog($e->getMessage());
     }
     return array($return, $total, $pages);
 }
 /**
  * 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;
 }
 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');
 }
Exemple #4
0
 public function getLastPage(PropelModelPager $pager)
 {
     return $pager->getLastPage();
 }
Exemple #5
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;
 }