예제 #1
0
 public function testGetItems()
 {
     $this->mockSelect->expects($this->once())->method('limit')->with($this->equalTo(10));
     $this->mockSelect->expects($this->once())->method('offset')->with($this->equalTo(2));
     $items = $this->dbSelect->getItems(2, 10);
     $this->assertInstanceOf('Zend\\Db\\ResultSet\\ResultSet', $items);
 }
예제 #2
0
파일: DbSelectTest.php 프로젝트: Rovak/zf2
 public function testGetsItemsAtOffsetTen()
 {
     $actual = $this->_adapter->getItems(10, 10);
     $i = 11;
     foreach ($actual as $item) {
         $this->assertEquals($i, $item['number']);
         $i++;
     }
 }
예제 #3
0
 public function getItems($a, $b)
 {
     $items = parent::getItems($a, $b);
     $return = array();
     foreach ($items as $item) {
         $return[] = $item;
     }
     return $return;
 }
예제 #4
0
 /**
  * Paginate models.
  * Minimum $page must be 1, not 0.
  *
  * @var int|string $page
  * @var int|string $perPage
  */
 public function paginate($page, $perPage = null)
 {
     $page = (int) $page;
     if ($page < 1) {
         $page = 1;
     }
     if ($perPage === null) {
         if (!($perPage = $this->select->getRawState('limit'))) {
             throw new Exception\InvalidArgumentException("No per page passed and no limit is set");
         }
     }
     $modelClass = $this->modelClass;
     $paginator = new Paginator($this->select, $modelClass::adapter());
     $items = $paginator->getItems(($page - 1) * $perPage, $perPage);
     $collection = $this->buildCollection($items->toArray());
     $collection->setPage($page);
     $collection->setPerPage($perPage);
     $collection->setPaginator($paginator);
     return $collection;
 }
예제 #5
0
 /**
  * Paginate models.
  * Minimum $page must be 1, not 0.
  *
  * @var int|string $page
  * @var int|string $perPage
  * @return array
  */
 public function paginate($page, $perPage = null)
 {
     if ($page < 1) {
         $page = 1;
     }
     $paginator = new Paginator($this->select, $this->adapter());
     $items = $paginator->getItems(($page - 1) * $perPage, $perPage);
     return $items->toArray();
 }