- <?php
- class Oracle_Db extends BaseObject {
- var $db;
- var $debug;
- var $db_connection_handle;
- var $connection_init;
- Function Oracle_Db( $db_config = '' ) {
- $this->BaseObject( 'Oracle_Db' );
- if ( is_object( $db_config ) ) {
- $this->db = $db_config;
- } else {
- $this->db = new DbDefaults();
- }
- $this->debug = new Debug();
- $this->debug->prefix = 'Oracle_Db::MAIN';
- $this->db_connection_handle = false;
- $this->connection_init = false;
- } /* END Oracle_Db() */
- Function BuildConnectString() {
- if ( $this->db->connect_string == '' ) {
- $this->db->Build_OracleConnectString();
- }
- } /* END BuildConnectionString */
- Function CreateConnection() {
- /* TODO Add persistent mode to oracles php driver */
- $this->BuildConnectString();
- if ( $this->connection_init == false ) {
- $open_connection = 0;
- $this->debug->On();
- /* Open the connection to the database */
- if ( !(
- $this->db_connection_handle = @OCIPLogon(
- $this->db->user_name,
- $this->db->password,
- $this->db->database
- ) ) ) {
- $this->debug->Message(
- 'Database Invalid Username / Password Combo : ' . "n" .
- 'Db Connect string : ' . $this->db->connect_string . "n" .
- 'Db Username : ' . $this->db->user_name . "n" .
- 'Db Password : ' . $this->db->password . "n"
- );
- $this->connection_init = false;
- return false;
- }
- $this->connection_init = true;
- }
- return true;
- } /* END CreateConnection() */
- Function Open() { return $this->CreateConnection(); }
- Function DestroyConnection() {
- if ( $this->connection_init == true ) {
- if ( @OCILogoff( $this->db_connection_handle ) ) {
- return array( true );
- } else {
- return array( false );
- }
- }
- }
- Function Close() { return $this->DestroyConnection(); }
- Function PrepareSql( $sql_stmt ) {
- $temp = new Oracle_DbDriver();
- $temp->db_connection_handle = $this->db_connection_handle;
- $temp->sql_statement = $sql_stmt;
- $temp->debug->debug = $this->debug->debug;
- return $temp;
- }
- Function Prepare( $sql_stmt ) {
- return $this->PrepareSql( $sql_stmt );
- }
- Function ListAllTables() {
- /* select table_name from all_tables; */
- $my_arr = Array();
- return Array( true, $my_arr );
- }
- } /* END Oracle_Db class */
- ?>