|
public function indexAction()
{
$this->view->title = "Co. Albums";
$Album = new Album();
// Define limit
$count = 5;
// Get total rows
$totalRows = $Album->fetchAll()->count();
// Get total pages
$totalPages = ceil($totalRows / $count);
// Define current page
$page = (int)$this->_getParam("page");
if ($page < 1 || $page > $totalPages) $page = 1;
// Define offset
$offset = ($page - 1) * $count;
$this->view->totalRows = $totalRows;
$this->view->totalPages = $totalPages;
$this->view->offset = $offset;
$this->view->count = $count;
$this->view->page = $page;
$this->view->albums = $Album->fetchAll(null, null, $count, $offset)->toArray();
}
|