class RSPage {
var $Debug = 0;
var $sqoe = 1; // sqoe= show query on error
var $Link_ID = 0;
var $Record = array();
var $Row;
var $numRow;
var $Parse;
var $Error = "";
var $m_timeFmt = "YYYY-MM-DD HH24:MI:SS";
var $m_num=-1;
var $m_sql;
var $m_pageSize=10;
var $m_cmt;
var $m_curPage=1;
function open($DB_Link)
{
$this->Link_ID = $DB_Link;
}
function query($Query_String,$page=1,$cnt=-1,$size=10) {
if($Query_String=="")
{
echo "執行語句不能為空!";
return false;
}
if(!$page)
$page = 1;
if(!$cnt)
$cnt = -1;
$this->m_pageSize = $size;
if($this->Parse){
MySQL_free_result($this->Parse);
}
if($cnt!=-1){
$this->m_num = $cnt;
}
else{
$result = MySQL_query($Query_String, $this->Link_ID);
if(!$result){
$this->Error=MySQL_error($this->Link_ID);
}
else{
$this->m_num = MySQL_num_rows($result);
}
/*
$cntsql = "select count(*) max_num from ($Query_String)";
$maxnum = 0;
$result = MySQL_query($sqlstr,$this->Link_ID);
$ret = MySQL_fetch_array($result);
MySQL_free_result($result);
if(!$ret) {
$this->Error=MySQL_error($this->Link_ID);
}
else {
&
您正在看的MySQL教程是:我的一個PHP_MySQL分頁類。nbsp; $this->m_num = $ret["max_num"];
}
*/
}
$pageCount = $this->getPageCount();
$pageSize = $this->getPageSize();
if($page>$pageCount)$page=$pageCount;
if($page<1)$page=1;
$this->m_curPage=$page;
$posBegin = ($page-1)*$pageSize;
$posEnd = $posBegin + $pageSize;
$Query_String = "$Query_String LIMIT $posBegin,$posEnd";
$this->Parse=MySQL_query($Query_String,