MySQL分页模型(Pagination.php)

幻城沙漠寒

幻城沙漠寒

2016-02-19 14:09

下面,图老师小编带您去了解一下MySQL分页模型(Pagination.php),生活就是不断的发现新事物,get新技能~

class Pagination {
        var $pageSize;        //页大小
        var $pageNo;                //当前页码
        var $rowCount;        //记录总数
        var $pageCount;        //总页数
        var $records;                //当前页记录
        var $currentPageSize;        //当前页记录总数
        var $currentPageStartNo;     //当前页开始记录号

        //判断是否有电脑教程之家 http://www.pcppc.cn
        function hasNextPage() {
                return $this-pageNo $this-pageCount;
        }
        //取得电脑教程之家 http://www.pcppc.cn页码
        function getNextPageNo() {
                return $this-pageNo + 1;
        }

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

        //判断是否有上一页
        function hasPriorPage() {
                return $this-pageNo 1;
        }
        //取得上一页页码
        function getPriorPageNo() {
                return $this-pageNo - 1;
        }

        //判断是否第一页
        function isFirstPage(){
                return $this-pageNo == 1 || $this-pageCount==0;
        }

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/bianchengyuyan/)

        //判断是否最后一页
        function isLastPage(){
                return $this-pageNo == $this-pageCount || $this-pageCount==0;
        }

        //装载某一页数据,成功则返回true,失败则返回false
        //        dataMaker是一个函数名,用于将一条记录转换为一个对象
        //        有一个参数为当前记录所有字段的值(一个以数字或字段名为索引的数组)
        function load($con, $sql, $dataMaker, $pageSize, $pageNo){
                //页大小和当前页码必须=1
                if( $pageSize1 || $pageNo1 ) return false;

                //查询
                if( $rst = @mysql_que


MySQL教程是:MySQL分页模型(Pagination.php)。ry($sql, $con) ){
                        $this-pageSize = $pageSize;
                        $this-pageNo = $pageNo;

                        $this-rowCount = @mysql_num_rows($rst);
                        $this-pageCount = (int)(($this-rowCount + $this-pageSize - 1) / $this-pageSize);
                        $this-records = array();

                        //将光标移动到指定页的第一条记录前
                        $this-currentPageStartNo = ($this-pageNo - 1) * $this-pageSize + 1;
                        $firstRowNo = $this-currentPageStartNo;
                        while( --$firstRowNo0 && @mysql_fetch_array($rst) );

                        //取出指定页的数据
                        $read = 0;
                        $this-currentPageSize = 0;
                        while( $read$this-pageSize && $row=@mysql_fetch_array($rst) ){
                                $this-records[$this-currentPageSize++] = $dataMaker($row);
                                $read++;
                        }
                }
                else{
                        return false;
                }

                return true;
        }
};

展开更多 50%)
分享

猜你喜欢

MySQL分页模型(Pagination.php)

编程语言 网络编程
MySQL分页模型(Pagination.php)

php入门mysql分页PageQuery类

编程语言 网络编程
php入门mysql分页PageQuery类

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

php入门mysql分页调用程序

编程语言 网络编程
php入门mysql分页调用程序

php入门mysql分页dbClass类

编程语言 网络编程
php入门mysql分页dbClass类

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

php分页函数

Web开发
php分页函数

php分页类

Web开发
php分页类

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Mysql数据进行并发锁定

Mysql数据进行并发锁定

VBA数组的升序、降序

VBA数组的升序、降序
下拉加载更多内容 ↓