简体   繁体   中英

Confused with Zend_Paginator

I am really confused with how Zend_Paginator works...

$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) return 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) returns 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) return 7...

For Zend Pagination, http://zendgeek.blogspot.com/2009/07/zend-pagination-example.html is having a simple example. This is very simple to integrate, try it.......

After reading try this,

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM