试用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生成随机密码

纯php生成随机密码

php生成一个随机的密码,方便快捷,可以随机生成安全可靠的密码。 分享代码如下 <?php header("Content-type:text/html;chars...

优化php效率,提高php性能的一些方法

1、在可以用file_get_contents替代file、fopen、feof、fgets等系列方法的情况下,尽量用 file_get_contents,因为他的效率高得多!但是要注意...

高级php注入方法集锦第1/2页

'%23  ' and passWord='mypass  id=-1 union select 1,1,1&nbs...

php中自定义函数dump查看数组信息类似var_dump

这个很早就有了,比php自带的var_dump好用多了。 复制代码 代码如下: function dump($vars, $label = '', $return = false) {...

百度工程师讲PHP函数的实现原理及性能分析(二)

百度工程师讲PHP函数的实现原理及性能分析(二)

类方法 类方法其执行原理和用户函数是相同的,也是翻译成opcodes顺次调用。类的实现,zend用一个数据结构zend_class_entry来实现,里面保存了类相关的一些基本信息。这个...