Here we will not talk about how to enable the oci8 extension for php. Let's talk about how to operate Oracle in php. Here we will only share with you the php class. If you need it, you can refer to it.
Here we will not talk about how to enable the oci8 extension for php. Let's talk about how to operate Oracle in php. Here we will only share with you the php class. If you need it, you can refer to it.
I would like to share with you a php operation class on Oracle.
Oracle_db.class.php
<? Phpclass 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 );}//}
The above is all the content of this article. I hope you will like it.