controller:
<?php
public function indexAction()
{
$currentPage = $this->request->getQuery('page', 'int');
$users = Users::find();
$paginator = new \Phalcon\Paginator\Adapter\NativeArray(
array(
"data" => $users,
"limit"=> 1,
"page" => $currentPage
)
);
$page = $paginator->getPaginate();
$this->view->setVar("page", $page);
}
?>
in view:
<html>
<table>
<tr>
<th>Id</th>
<th>Name</th>
<th>Type</th>
</tr>
<?php foreach ($page->items as $item) { ?>
<tr>
<td><?php echo $item->_id; ?></td>
<td><?php echo $item->name; ?></td>
</tr>
<?php } ?>
</table>
<a href="/index/index">First</a>
<a href="/index/index?page=<?= $page->before; ?>">Previous</a>
<a href="/index/index?page=<?= $page->next; ?>">Next</a>
<a href="/index/index?page=<?= $page->last; ?>">Last</a>
<?php echo "You are in page ", $page->current, " of ", $page->total_pages; ?>
</html>