你有没有看唠叨的php+mysql分页显示呀
如果是orcal的odbc连接不就改改数据库连接与读取数据的几个相关函数可以了吗????http://community.csdn.net/Expert/topic/3093/3093475.xml?temp=.7862512

解决方案 »

  1.   

    <?php
    /*********************************
    # Class Name: Ora_page          
    # Purpose:php&oracle分页类     
    # Version: 1.0                 
    # Author:  piner           
    **********************************/class Ora_page{
    //start class 
    var $offset;              //##::   偏移量       
    var $totalNums;           //##::   记录总数     
    var $where;               //##::   显示条件  
    var $order;               //##::   显示排序
    var $maxLine;             //##::   每页显示行数         
    var $totalPages;          //##::   总页数      
    var $currentPage;         //##::   当前页      
    var $parameter;           //##::   传递的参数  
    var $db_obj;
       /********************************************************
        :::::::              功能:  构造函数              ::::::::
        :::::::  示例: $SYS=array(                       ::::::::
        :::::::    "currentPage" =>$cpage,     ::::::::
        :::::::    "totalPage"   =>10          ::::::::  
        :::::::       );                               ::::::::
        :::::::        $obj = Ora_page($SYS);           ::::::::
       *********************************************************/
    function Ora_page($SET_PAGE_VARS){
       $this->currentPage      = $SET_PAGE_VARS['currentPage'];
       $this->maxLine          = $SET_PAGE_VARS['maxLine'];
       $this-> init();
    }
       /*******************************************************
        :::::::::::       连接 oracle 数据库        ::::::::::::
       ********************************************************/
        function init(){
         $this-> db_obj = new DB_ora;
    }
        /******************************************************
     ::::::::     功能: 返回总记录数                 ::::::::
    *******************************************************/
        function totalNums(){
       return $this->totalNum;
    }   /********************************************************
        :::::::             功能: 设置显示条件              ::::::
    :::::::   示例:where id='$id' order by id desc    ::::::
       *********************************************************/
    function setCondition($where){
       $this->where  = $where;
    //   $this->order  = $order;
    }   /********************************************************
        ::::::::            功能: 设置传递参数              :::::::
    :::::::: 示例: $parameter=array("name"=>$name);   ::::::: 
    ::::::::      setParameter($parameter);           :::::::
       *********************************************************/
    function setParameter($parameter){
       if ( ! is_array($parameter) ) {
       print("Invalid:".$parameter." not array"); 
           exit;
       }
        while(list($key,$val) = each($parameter)) {
       $tmp[]          = $key."=".$val;
    }
    $string = implode("&",$tmp);
        $this->parameter   = $string;
    }   /********************************************************
        ::::::::                 功能: 读取数据            :::::::
       *********************************************************/
    function list_Record($sql) {
      global $Tconfig;
      $query = "select count(*) as allnum from (".$sql.")";
      //$query = "select count(*) as allnum from ".$tb." ".$this->where."";
      $this-> db_obj->query($query); 
      $this-> db_obj->next_record();
      $this-> totalNum = $this->db_obj-> Record['ALLNUM'];
      $this-> offset           = ($this->currentPage-1) * $this->maxLine;
      if ($this->totalNum > 0) { 
    $this-> db_obj->query($sql);
    @OCIFetchStatement($this->db_obj->Parse,$record,$this->offset,$this->maxLine,OCI_FETCHSTATEMENT_BY_ROW);
            //while($this->db_obj->next_record()){
    //   $record =  $this->db_obj->Record;
    //}

    return $record;
      }
    }    /********************************************************
        ::::::::             功能: 读取当前页,总页数          ::::
       *********************************************************/
    function curr_Total(){
            $this->totalPage = ceil($this->totalNum / $this->maxLine);
    $total = $this->totalPage?$this->totalPage:"1";
        $ctPage = "第".$this->currentPage."页&nbsp;共".$total."页&nbsp;共".$this->totalNum."条记录";
        return $ctPage;
    }   /*********************************************************
        ::::::::    功能:读取首页,上页,下页,末页         :::::::::
    ::::::::    返回值:数组                          :::::::::
    ::::::::    示例:mainPage=$obj->main_Page()   :::::::::
    ::::::::    首页连接->mainPage['first']          :::::::::
    ::::::::    上一页连接->mainPage['prev']          :::::::::
    ::::::::    下一页连接->mainPage['next']          :::::::::
    ::::::::    末页连接->mainPage['last']            :::::::::
       **********************************************************/
        function main_Page(){
       $prev      = $this->currentPage - 1;
       $next      = $this->currentPage + 1;
       if ($this->currentPage != 1){
       $listPage['first'] = "<a class=link href=".$PHP_SELF."?Cpage=1&".$this->parameter."><font face=webdings>9</font></a>";
       }else{
           $listPage['first'] = "<font face=webdings>9</font>";
       }    if ($this->currentPage >  1){
       $listPage['prev']  = "<a class=link href=".$PHP_SELF."?Cpage=".$prev."&".$this->parameter."><font face=webdings>7</font></a>";
       }else{
          $listPage['prev']  = "<font face=webdings>7</font>";
       }
       if ($this->currentPage < $this->totalPage){
       $listPage['next']  = "<a class=link href=".$PHP_SELF."?Cpage=".$next."&".$this->parameter."><font face=webdings>8</font></a>";
       }else{
          $listPage['next']  = "<font face=webdings>8</font>";
       }
       if ($this->currentPage < $this->totalPage){
       $listPage['last']  = "<a class=link href=".$PHP_SELF."?Cpage=".$this->totalPage."&".$this->parameter."><font face=webdings>:</font></a>";
       }else{
          $listPage['last']  = "<font face=webdings>:</font>";
       }
       return $listPage;
       }  /*********************************************************
       :::::::::  功能:读取页数以数字显示:1 2 3.....     :::::::::
      **********************************************************/
       function number_Pages(){
         for($i=1;$i<=$this->totalPage;$i++){
        if(($i+10 >= $this->currentPage) and ($i-10 <= $this->currentPage))
            $numberPage.= ($this->currentPage!=$i)?"<a href=".$PHP_SELF."?Cpage=".$i."&".$this->parameter.">".$i."</a>&nbsp;":$i."&nbsp;";
      }
      return $numberPage;
       }   // end class
    }
    ?>
      

  2.   

    $SET_PAGE_VARS['maxLine'] = 10; //每页显示记录
    $SET_PAGE_VARS['currentPage'] = $Cpage ? $Cpage : 1; //当前页码
    $oraPage = new ($SET_PAGE_VARS);$sql = "select id,name from table";
    $record = $oraPage-> list_Record($sql);for($i=0; $i<count($record); $i++)  //显示记录
    {
           echo $record[$i]['id'];        
    }echo $oraPage->curr_Total();  //显示当前页,总页码等
    $mainPage = $oraPage->main_Page();
    echo $mainPage['first'];   //首页
    echo $mainPage['prev'];    //上一页
    echo $mainPage['next'];    //下一页
    echo $mainPage['last'];    //最后一页
      

  3.   

    更正:$oraPage = new ($SET_PAGE_VARS) =》$oraPage = new Ora_page($SET_PAGE_VARS);
      

  4.   

    非常感谢!再请教一下:
    function init(){
         $this-> db_obj = new DB_ora;
    }
    这个就能连接数据库了吗?好像还不行吧?
      

  5.   

    你可以用phplib里面的oracle数据库操作类呀
      

  6.   

    其实ORACLE分页的类没有必要独立出来,在PHP+MYSQL的分页程序里,不要用limit语句,而改用data_seek()函数来移动游标,这样的话,MSSQL,MYSQL,ORACLE都可以公用一个分页类。呵呵,抛砖引玉了....
      

  7.   

    ljcao(龙威) 大哥,你所说的data_seek()函数如何用啊?我就尝试用过MYSQL的分页类,就因为不能定位游标而永远显示第一次取出的那几条记录……
      

  8.   

    我比较喜欢PHPBB的oracle驱动类.借鉴PHPBB的写法,写出来的PHP程序可以使用所有的主流数据库.
      

  9.   

    haixiao53(海啸) 
    这位大哥,PHPBB是什么东东啊?