我真的对Zend_Paginator的工作方式感到困惑...

$dbProducts = $this->_table->fetchAll($this->_table->select());
//$dbProducts = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($this->_table->select()));
//$dbProducts->setItemCountPerPage(4);
//$dbProducts->setCurrentPageNumber(1);


count($ dbProducts)返回27 ...

//$dbProducts = $this->_table->fetchAll($this->_table->select());
$dbProducts = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($this->_table->select()));
//$dbProducts->setItemCountPerPage(4);
//$dbProducts->setCurrentPageNumber(1);


count($ dbProducts)返回3 ...

//$dbProducts = $this->_table->fetchAll($this->_table->select());
$dbProducts = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($this->_table->select()));
$dbProducts->setItemCountPerPage(4);
$dbProducts->setCurrentPageNumber(1);


count($ dbProducts)返回7 ...

最佳答案

对于Zend分页,http://zendgeek.blogspot.com/2009/07/zend-pagination-example.html有一个简单的示例。集成起来非常简单,尝试一下。

看完后试试这个,

        $page = $this->_getParam('page', 1);
        $paginator = Zend_Paginator::factory($dbProducts);
        $paginator->setItemCountPerPage(20);
        $paginator->setCurrentPageNumber($page);

        $this->view->records = $paginator;

09-25 15:22