试用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 json_encode()函数返回json数据实例代码

json_encode()函数用法。 echo json_encode(array('a'=>'bbbb','c'=>'ddddd'); 这样就会生成一个标准的json格式的...

PHP使用strstr()函数获取指定字符串后所有字符的方法

本文实例讲述了PHP使用strstr()函数获取指定字符串后所有字符的方法。分享给大家供大家参考,具体如下: PHP的strstr()函数可搜索字符串在另一字符串中的第一次出现位置,并返...

PHP输出图像imagegif、imagejpeg与imagepng函数用法分析

本文实例讲述了PHP输出图像imagegif、imagejpeg与imagepng函数用法。分享给大家供大家参考,具体如下: imagegif()、imagejpeg()、imagepn...

php封装db类连接sqlite3数据库的方法实例

前言 SQLite3扩展名在PHP 5.3.0+以上都会默认启用。可以在编译时使用--without-sqlite3来禁用它。 Windows用户可通过启用php_sqlite3.dll...

如何使用脚本模仿登陆过程

查看他的登陆页面的代码, 看他提交到哪个页面, 变量是什么。复制代码 代码如下:<form method="post" action="lo...