I want to set pagination for large collection of data set say tens of thousands. If you fetch all data at once performance will be slow. So I need a better approach:
In my controller I have the code as given:
$result = $result = $this->fetchAll($this->select()
->where('id='.$id)
->order('date DESC'))->toArray();
$paginator = Zend_Paginator::factory($data);
$pageNumber = $this->_getParam('page');
$paginator->setCurrentPageNumber($pageNumber);
$paginator->setItemCountPerPage(10);
$this->view->data = $paginator;
This code will fetch all database contents at once.