Home >Database >Mysql Tutorial >我的一个php_mysql分页类_MySQL

我的一个php_mysql分页类_MySQL

WBOY
WBOYOriginal
2016-06-01 13:55:291024browse

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 {
        &

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