php连接 Oracle数据库的步骤!

//以面向对象的思想连接数据库

class Oracle {
 var $db="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.136.13)(PORT=1521))(CONNECT_DATA=  (SID=orcl)))";
 var $dbname="crm";//连接数据库的用户名
 var $dbpwd="crm";//连接数据库的用户名密码
 var $dblink="";//连接数据库

    function Oracle() {
     $this->dblink=oci_connect($this->dbname,$this->dbpwd,$this->db);
    }

}
?>

 

          session_start();
          $username = $_SESSION['USERNAME'];
          /*if(!isset($username)){
             header("Location:http://".$_SERVER["SERVER_NAME"]."/ibm2crm/index.php");
             exit;
          }*/
   ?>
 require_once("../../../web/include/page.php");
 ?>


     require_once("../../../lib/db/Oracle.class.php");
           $db = new Oracle();
           $sql ="begin userPKG.pageUser(:pageno,:pagesize,:depcur,:totalrecore);end;";
           $stmt = oci_parse($db->dblink,$sql);

           $cur=oci_new_cursor($db->dblink);

          oci_bind_by_name($stmt,"pageno",$pageno,3);
          oci_bind_by_name($stmt,"pagesize",$pagesize,3);
          oci_bind_by_name($stmt,"depcur",$cur,-1,OCI_B_CURSOR);
          oci_bind_by_name($stmt,"totalrecore",$totalrecord,2);
    oci_execute($stmt);
    oci_execute($cur);

    $a=1;
    //$color="this.bgColor = '#C2E9FC'";
    //$color2="this.bgColor = 'FFFFFF'";
    if($cur!=null)
    {  if($_SESSION['USER_ISMANAGER'])
      {
        while($row=oci_fetch_array($cur))
       {
          $stmt = ociparse($db->dblink, "select dname from crm_department where deptno='$row[2]'");
          OCIDefineByName($stmt,"DNAME",&$dname);
          ociexecute($stmt);
          while(ocifetch($stmt))

          echo "";
          echo "".(($pageno-1)*$pagesize+$a++)."";
          echo "".$row[0]."";
        echo "".$row[5]."";

          echo "".$row[6]."";
       if($row[7]==1)
      {
       echo "".$row[8]."/".$dname."[负责]";
      }
      else
      {
       echo "".$row[8]."/".$dname."";
      }

          echo "".$row[9]."";

          echo "修改  删除";
          echo "";
        }
      }else
      {
       echo "";
          echo "".(($pageno-1)*$pagesize+$a++)."";
          echo "".$_SESSION['USERS_ID']."";
        echo "".$_SESSION['USERNAME']."";

          echo "".$_SESSION['USER_SEX']."";
     echo "".$_SESSION['USER_TEL']."";
          echo "".$_SESSION['USER_EMAIL']."";

          echo "修改                  echo "'>删除";
          echo "";
      }

    }
     $totalPage = floor(($totalrecord-1)/$pagesize+1);

?>

 
        style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; LINE-HEIGHT: 22px; PADDING-TOP: 2px; BORDER-BOTTOM: #e8e8e8 1px solid; HEIGHT: 22px"
    align=middle width="100%" bgColor=#ffffff colSpan=7>
     


       
       
       
         

         


         
          if($_SESSION['USER_ISMANAGER']){
     if($pageno==1){?>
      首页  上一页
          }else{?>
      首页  上一页
          }
     ?> 

         if($totalPage==$pageno){?>
     下一页 末页
        }else{
     ?>
     下一页 末页
        }
    ?>第



           
           
页,共页  总记录数:

你可能感兴趣的:(php连接 Oracle数据库的步骤!)