试用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获取YouTube视频信息的方法

php获取YouTube视频信息的方法

本文实例讲述了php获取YouTube视频信息的方法。分享给大家供大家参考。具体分析如下: YouTube的视频地址格式 https://www.youtube.com/watch...

php扩展ZF——Validate扩展

之前写了一片文章关于如何在ZF0.6版本下扩展ZF的。这篇应该说是类似的文章,但环境换成ZF1.0RC1版本了。      在开始ZF扩...

php trim 去除空字符的定义与语法介绍

定义和用法 trim() 函数从字符串的两端删除空白字符和其他预定义字符。 语法 trim(string,charlist)参数 描述 string 必需。规定要检查的字符串。 char...

PHP面向对象编程快速入门

【摘 要】面向对象编程(OOP)是我们编程的一项基本技能,PHP4对OOP提供了良 好的支持。如何使用OOP的思想来进行PHP的高级编程,对于提高PHP编程能力和&n...

使用php检测用户当前使用的浏览器是否为IE浏览器

复制代码 代码如下: /** * 检测用户当前浏览器 * @return boolean 是否ie浏览器 */ function chk_ie_browser() { $userbrow...