I try to help you based on what I have in my ZF project.
So, in your class Model_DbTable_Order you can defined a method called e.g. getOnePageOfOrderEntries() as follows:
/**
* Return one page of order entries
*
* @param int $page page number
* @return Zend_Paginator Zend_Paginator
*/
public function getOnePageOfOrderEntries($page=1) {
$query = $this->select();
$paginator = new Zend_Paginator(
new Zend_Paginator_Adapter_DbTableSelect($query)
);
$paginator->setItemCountPerPage(100);
$paginator->setCurrentPageNumber($page);
return $paginator;
}
Than in indexAction you can have something like this:
public function indexAction()
{
$this->view->title = "My Orders";
$this->view->headTitle($this->view->title, 'PREPEND');
$orders = new Model_DbTable_Orders();
//$this->view->orders = $orders->fetchAll();
$page = $this->_request->getParam('page');
if (empty($page)) { $page = 1; }
$paginator = $orders->getOnePageOfOrderEntries($page);
$this->view->paginator = $paginator;
}
In your index.phtml view you could have something similar to this:
<?php if (count($this->paginator)): ?>
<table>
<tr>
<th>Name</th>
<th>Quantity</th>
<th> </th>
</tr>
<?php foreach($this->paginator as $order): ?>
<tr>
<td><?php echo $order->name;?></td>
<td><?php echo $order->quantity;?></td>
<td><!-- And the rest what you want --></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<?php echo $this->paginationControl($this->paginator,
'Sliding','partial/my_pagination_control.phtml'); ?>
Where my_pagination_control.phtml is as follows (this is just copy-paste what I have and it is from the ZF Reference quide):
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->previous)); ?>">
Previous
</a> <span class="bar"> | </span>
<?php else: ?>
<span class="disabled"> Previous</span> <span class="bar"> | </span>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?php echo $this->url(array('page' => $page)); ?>">
<?php echo $page; ?>
</a> <span class="bar"> | </span>
<?php else: ?>
<?php echo $page; ?> <span class="bar"> | </span>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url(array('page' => $this->next)); ?>">
Next
</a>
<?php else: ?>
<span class="disabled">Next </span>
<?php endif; ?>
</div>
<?php endif; ?>
Hope it will be useful.