Share a PHP action class for Oracle operations
Oracle_db.class.php
<?php class oracle_db{public $link;
Public Function __construct () {$this->link= $this->connect ();
if (! $this->link) {echo "Connection failed";
Exit
} Public Function connect () {return Oci_connect (' demo ', ' demo ', ' Localhost/xe ', ' Al32utf8 ');
The Public function execute ($sql) {$result =false;
$stid =oci_parse ($this->link, $sql);
if ($stid) {$result =oci_execute ($stid);
Return Array ($stid, $result);
The Public Function Fetch_assoc ($stid) {return Oci_fetch_assoc ($stid);
The Public Function Fetch_one ($stid) {$arr = $this->fetch_assoc ($stid);
$this->free ($stid);
return $arr;
The Public Function Fetch_all ($stid) {$arr =array ();
while ($row = $this->fetch_assoc ($stid)) {$arr []= $row;
$this->free ($stid);
return $arr;
The Public Function num_rows ($stmt) {return oci_num_rows ($stmt);
Public Function error () {return oci_error ($this->link); } public functionFree ($stid) {return oci_free_statement ($stid);
The Public Function server_version () {return oci_server_version ($this->link);
The Public Function client_version () {return oci_client_version ();
The Public Function __destruct () {return oci_close ($this->link);
}
//
}
The above is the entire contents of this article, I hope you can enjoy