Php oci8 test, oci8 Test
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 ');
}
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 );
}
//
}