试用php中oci8扩展
给大家分享个php操作Oracle的操作类
Oracle_db.class.php
<?php classOracle_db{ public$link; publicfunction__construct(){ $this->link=$this->connect(); if(!$this->link){ echo"连接失败"; exit; } } publicfunctionconnect(){ returnoci_connect('demo','demo','localhost/xe','AL32UTF8'); } publicfunctionexecute($sql){ $result=false; $stid=oci_parse($this->link,$sql); if($stid){ $result=oci_execute($stid); } returnarray($stid,$result); } publicfunctionfetch_assoc($stid){ returnoci_fetch_assoc($stid); } publicfunctionfetch_one($stid){ $arr=$this->fetch_assoc($stid); $this->free($stid); return$arr; } publicfunctionfetch_all($stid){ $arr=array(); while($row=$this->fetch_assoc($stid)){ $arr[]=$row; } $this->free($stid); return$arr; } publicfunctionnum_rows($stmt){ returnoci_num_rows($stmt); } publicfunctionerror(){ returnoci_error($this->link); } publicfunctionfree($stid){ returnoci_free_statement($stid); } publicfunctionserver_version(){ returnoci_server_version($this->link); } publicfunctionclient_version(){ returnoci_client_version(); } publicfunction__destruct(){ returnoci_close($this->link); } // }
以上所述就是本文的全部内容了,希望大家能够喜欢