
使用ThinkPHP,解决应用面开发中的大多数需要,借鉴了国外优秀的框架和模式,在模版引擎、缓存机制、认证机制和扩展性方面均有独特的表现。因为ThinkPHP是遵循Apache2开源许可协议而发布的,所以这也意味着你可以免费使用ThinkPHP,也可以把你的ThinkPHP应用采用商业闭源模式发布。
PHP教学资料:http://blog.0hi.cn/using-of-paging-in-thinkphp.html
ThinkPHP中分页的使用
以Page类和limit方法为例来说明:
1.<?php
2.class IndexAction extends Action{
3. public function index() {
4. //自定义
5. $Form=M(“User”); //实例化User对象
6. import(“@.Util.Page”); //导入分页类
7. $count = $User->count(); //计算总记录数
8. $page = new Page ( $count, 15 ); //实例化分页类 传入总记录数和每页显示的记录数
9. $page = $page->show (); // 分页显示输出
10. $this->assign ( “list”, $list ); //赋值数据集
11. $this->assign(“page”, $page); //赋值分页输出
12. $this->display(); //赋值模板
13. }
14.
15. public function Mypage(){
16. //普通方式实现分页
17. $Form=M(“User”); //实例化User对象
18. import(“@.Util.Page”); //导入分页类
19. $count = $User->count(); //计算总记录数
20. $page = new Page ( $count, 15 ); //实例化分页类 传入总记录数和每页显示的记录数
21. $list=$Form->limit($p->firstRow.’,’.$p->listRows)->order(‘id desc’)->findAll();
22. $page = $page->show (); // 分页显示输出
23. $this->assign ( “page”, $page ); //赋值分页输出
24. $this->assign ( “list”, $list ); //赋值数据集
25. $this->display(); //赋值模板
26.}
27.?>
最佳答案