Home > php教程 > PHP源码 > 用PHP MySQL进行分页的详细说明(二)

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

WBOY
Release: 2016-06-08 17:33:07
Original
1062 people have browsed it
<script>ec(2);</script>

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;
}
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template