首页 > php代码 > 用PHP MySQL进行分页的详细说明(二)

用PHP MySQL进行分页的详细说明(二)

<?php
function getDataLink() {
    if ($this->numItems) {
        global $db;
        $PageID = $this->CurrentPageID;
        $from = ($PageID - 1) * $this->PageSize;
        $count = $this->PageSize;
        $link = $db->limitQuery($this->sql, $from, $count); //使用Pear DB::limitQuery方法保证数据库兼容性
        return $link;
    } else {
        return false;
    }
}
/***
 *
 * 以二维数组的格式返回结果集
 *
 ***/
function getPageData() {
    if ($this->numItems) {
        if ($res = $this->getDataLink()) {
            if ($res->numRows()) {
                while ($row = $res->fetchRow()) {
                    $result[] = $row;
                }
            } else {
                $result = array();
            }
            return $result;
        } else {
            return false;
        }
    } else {
        return false;
    }
}


本文地址:http://www.phprm.com/code/dbe1328fb31be0b3f4dd600f912b36a1.html

转载随意,但请附上文章地址:-)

标签:none

发表留言