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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:33:071069browse
<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;
}
}

Statement:
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
Previous article:用PHP控制FTP文件上传Next article:格式化显示时间