Zend Framework分页类用法详解(2)

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常见数据库操作技巧汇总

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/8399dc5a7d86725987b04d9c71aa5c62.html