require_once 'Zend/Pagination.php'; $Users = new Users(); //$rows = $Users->getAdapter()->fetchOne("select count(*) from users where `role`!='admin'"); //recorde count $rows = $Users->fetchAll("`role`!='admin'")->count(); //查询记录总数 $rowsPerPage = 5; //perPage recordes $curPage = 1; if($this->_request->getParam('page')) { $curPage = $this->_request->getParam('page'); } //search data and display $this->view->users = $Users->fetchAll("`role`!='admin'",'id desc',$rowsPerPage,($curPage-1)*$rowsPerPage)->toArray(); $Pager = new XY_Pagination($rows,$rowsPerPage); $this->view->pagebar = $Pager->getNavigation();
3、在view中调用分页更简单了。
pagebar?>
或者在smarty模板情况下
<{$pagebar}>
更多关于zend相关内容感兴趣的读者可查看本站专题:《Zend FrameWork框架入门教程》、《php优秀开发框架总结》、《Yii框架入门及常用技巧总结》、《ThinkPHP入门教程》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》