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); }
public function testGetsItemsAtOffsetTen() { $actual = $this->_adapter->getItems(10, 10); $i = 11; foreach ($actual as $item) { $this->assertEquals($i, $item['number']); $i++; } }
public function getItems($a, $b) { $items = parent::getItems($a, $b); $return = array(); foreach ($items as $item) { $return[] = $item; } return $return; }
/** * 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; }
/** * 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(); }