试用php中oci8扩展

yipeiwu_com5年前PHP代码库

给大家分享个php操作Oracle的操作类

Oracle_db.class.php

<?php
class Oracle_db{
  public $link;
  public function __construct(){
    $this->link=$this->connect();
    if(!$this->link){
      echo "连接失败";
      exit;
    }
  }
  public function connect(){
    return oci_connect('demo','demo','localhost/xe','AL32UTF8');
  }
  public function execute($sql){
    $result=false;
    $stid=oci_parse($this->link,$sql);
    if($stid){
      $result=oci_execute($stid);
    }
    return array($stid,$result);
  }
  public function fetch_assoc($stid){
    return oci_fetch_assoc($stid);
  }
  
  public function fetch_one($stid){
    $arr=$this->fetch_assoc($stid);
    $this->free($stid);
    return $arr;
  }
  public function fetch_all($stid){
    $arr=array();
    while($row=$this->fetch_assoc($stid)){
      $arr[]=$row;
    }
    $this->free($stid);
    return $arr;
  }
  public function num_rows($stmt){
    return oci_num_rows($stmt);
  }
  public function error(){
    return oci_error($this->link);
  }
  public function free($stid){
    return oci_free_statement($stid); 
  }
  public function server_version(){
    return oci_server_version($this->link);
  }
  public function client_version(){
    return oci_client_version();
  }
  public function __destruct(){
    return oci_close($this->link);
  }
  //
}

以上所述就是本文的全部内容了,希望大家能够喜欢

相关文章

php文件操作之小型留言本实例

本文实例讲述了php文件操作之小型留言本。分享给大家供大家参考。具体如下: Index.php文件如下: <?php $path = "DB/"; //定义路径 $...

php中获取指定IP的物理地址的代码(正则表达式)

php中获取指定IP的物理地址的代码(正则表达式)

自己搭建IP数据库占资源,而且更新不便,何不使用现成的IP查询呢?下面自己写了个获取IP物理地址的PHP代码(有一定的瑕疵,请高手不吝赐教) 复制代码 代码如下: <!DOCTYP...

用php过滤危险html代码的函数

#用户发布的html,过滤危险代码  function uh($str)  {  $farr = array(  "...

解析PHP的session过期设置

网上很多人给出了解答:修改php配置文件中的session.gc_maxlifetime。如果想了解更多session回收机制,继续阅读。(本文环境php5.2)概述:每一次php请求,...

PHP封装的page分页类定义与用法完整示例

PHP封装的page分页类定义与用法完整示例

本文实例讲述了PHP封装的page分页类定义与用法。分享给大家供大家参考,具体如下: 亲测有效,见下图=========> 1. 测试实例test.php <?...