Yesterday I came up with a small pagination component for the Zend Frameworks. It implements the Proxy pattern around a Zend_Db_Table object, and overloads the fetchAll method. The main problem I encountered here was to retrieve the total number of rows for the table. I'm using a Zend_Db_Select query for now, but I'll have to improve that. The component also features a view helper to draw the pagination links.
You'll find the code for the component and the view helper on my SVN.
And here is how it is used in the controller:
public function indexAction() {
$urls = new Riskle_Db_Table_Paginate(new Urls, $this->_getParam('page'));
$this->view->urlsList = $urls->fetchAll(null, 'datetime DESC');
$this->view->paginationInfos = $urls->getPaginationInfos();
}
The view helper takes paginationInfos as an argument:
echo $this->paginate($this->paginationInfos);
UPDATE
As pointed out by Guy, the _getPageCount method does not actually takes care of the $where condition, thus rendering the class inefficient as getting the real totel number of items. This issue will be adressed in an upcoming version of the class :-)
UPDATE
There's an updated version of this component available.