zoukankan      html  css  js  c++  java
  • ThinkPHP关于分页的使用

    在官方提供下载的实例文档中有一个关于分页的代码实例,原文如下:
    控制器IndexAction类
    <?php 
    class IndexAction extends Action{ 
        public function index() { 
                //自定义 
                $Form=M('Form'); 
                import("@.ORG.Page"); //导入分页类 
                $count = $Form->count();    //计算总数 
                $p = new Page ( $count, 5 ); 
                $list=$Form->limit($p->firstRow.','.$p->listRows)->order('id desc')->findAll(); 
                $p->setConfig('header','篇记录'); 
                $p->setConfig('prev',"<"); 
                $p->setConfig('next','>'); 
                $p->setConfig('first','<<'); 
                $p->setConfig('last','>>'); 
                $page = $p->show (); 
                $this->assign( "page", $page ); 
                $this->assign ( "list", $list ); 
                $this->display(); 
        } 
    
        public function Mypage(){ 
                //普通方式实现分页 
                $Form=M('Form'); 
                import("@.ORG.Page"); //导入分页类 
                $count = $Form->count();    //计算总数 
                $p = new Page ( $count, 5 ); 
                $list=$Form->limit($p->firstRow.','.$p->listRows)->order('id desc')->findAll(); 
                $page = $p->show (); 
                $this->assign ( "page", $page ); 
                $this->assign ( "list", $list ); 
                $this->display(); 
        } 
    } 
    ?> 


    其中的原理是 先导入分页类,然后计算总共的条数,最后用SQl的limit方法分段取数据。这个是最基本的一个分页方法。当然我们可以让这个操作变的完美一些。

    Meet so Meet. C plusplus I-PLUS....
  • 相关阅读:
    edgeR
    R中的运算符,条件语句,控制语句
    library-type:fr-unstanded vs fisrt-stand vs second-stanrd
    R的几个基础函数
    HTseq-count
    HISAT2的运用
    shell的符号总结
    python-tuple
    python -List
    win10 ubuntu18.0 LTS双系统安装
  • 原文地址:https://www.cnblogs.com/iplus/p/4490055.html
Copyright © 2011-2022 走看看