试用php中oci8扩展

yipeiwu_com6年前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使用timthumb生成缩略图的方法

本文实例讲述了php使用timthumb生成缩略图的方法。分享给大家供大家参考,具体如下: 生成缩列图有二种方式: 一、提前生成好,供调用 缩列图常规做法是,开始根据网站中的图片规格,要...

php 更新数据库中断的解决方法

即可解决: set_time_limit(900); 这个函数指定了当前所在php脚本的最大执行时间, 虽然设定值是900秒,实际上 最大执行时间=php.ini里的max_execut...

php几个预定义变量$_SERVER用法小结

本文实例总结了php几个预定义变量$_SERVER的用法。分享给大家供大家参考。具体如下: 复制代码 代码如下:<?php echo 'documentroot:'.$_S...

php替换字符串中间字符为省略号的方法

本文实例讲述了php替换字符串中间字符为省略号的方法。分享给大家供大家参考。具体分析如下: 对于一个长字符串,如果你只希望用户看到头尾的部分内容,隐藏掉中间内容,你可以使用这个php函数...

PHP array_multisort()函数的使用札记

函数  bool array_multisort ( array &$arr [, mixed $arg = SORT_ASC [, mixed $arg = SORT_REGULAR...