Oracle_Db.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:3k
源码类别:

WEB邮件程序

开发平台:

PHP

  1. <?php
  2. class Oracle_Db extends BaseObject {
  3.    var $db;
  4.    var $debug;
  5.    var $db_connection_handle;
  6.    var $connection_init;
  7.    Function Oracle_Db( $db_config = '' ) {
  8.       $this->BaseObject( 'Oracle_Db' );
  9.       if ( is_object( $db_config ) ) {
  10.          $this->db = $db_config;
  11.       } else {
  12.          $this->db = new DbDefaults();
  13.       }
  14.       $this->debug                  = new Debug();
  15.       $this->debug->prefix          = 'Oracle_Db::MAIN';
  16.       $this->db_connection_handle   = false;
  17.       $this->connection_init        = false;
  18.       } /* END Oracle_Db() */
  19.    Function BuildConnectString() {
  20.       if ( $this->db->connect_string == '' ) {
  21.          $this->db->Build_OracleConnectString();
  22.       }
  23.    } /* END BuildConnectionString */
  24.    Function CreateConnection() {
  25.       /* TODO Add persistent mode to oracles php driver */
  26.       $this->BuildConnectString();
  27.       if ( $this->connection_init == false ) {
  28.          $open_connection = 0;
  29.          $this->debug->On();
  30.          /* Open the connection to the database */
  31.          if ( !( 
  32.             $this->db_connection_handle = @OCIPLogon(
  33.                $this->db->user_name,
  34.                $this->db->password,
  35.                $this->db->database
  36.             ) ) ) {
  37.             $this->debug->Message( 
  38.             'Database Invalid Username / Password Combo : ' . "n" .
  39.             'Db Connect string : ' . $this->db->connect_string . "n" .
  40.             'Db Username       : ' . $this->db->user_name . "n" .
  41.             'Db Password       : ' . $this->db->password  . "n" 
  42.             );
  43.             $this->connection_init = false;
  44.             return false;
  45.          }
  46.          $this->connection_init = true;
  47.          }
  48.          return true;
  49.       } /* END CreateConnection() */
  50.    Function Open() { return $this->CreateConnection(); }
  51.    Function DestroyConnection() {
  52.       if ( $this->connection_init == true ) {
  53.          if ( @OCILogoff( $this->db_connection_handle ) ) {
  54.             return array( true );
  55.          } else {
  56.             return array( false );
  57.          }
  58.       }
  59.    }
  60.    Function Close() { return $this->DestroyConnection(); }
  61.    Function PrepareSql( $sql_stmt ) {
  62.       $temp = new Oracle_DbDriver();
  63.       $temp->db_connection_handle = $this->db_connection_handle;
  64.       $temp->sql_statement        = $sql_stmt;
  65.       $temp->debug->debug         = $this->debug->debug;
  66.       return $temp;
  67.    }
  68.    Function Prepare( $sql_stmt ) { 
  69.       return $this->PrepareSql( $sql_stmt ); 
  70.    }
  71.    Function ListAllTables() {
  72.          /* select table_name from all_tables; */
  73.          $my_arr = Array();
  74.          return Array( true, $my_arr );
  75.    }
  76. } /* END Oracle_Db class */
  77. ?>