Ejemplo n.º 1
0
 function __construct($pConnectionHash = NULL)
 {
     global $ADODB_FETCH_MODE;
     if (is_null($pConnectionHash)) {
         global $gBitDbType, $gBitDbHost, $gBitDbUser, $gBitDbPassword, $gBitDbName;
         $pConnectionHash['db_type'] = $gBitDbType;
         $pConnectionHash['db_host'] = $gBitDbHost;
         $pConnectionHash['db_user'] = $gBitDbUser;
         $pConnectionHash['db_password'] = $gBitDbPassword;
         $pConnectionHash['db_name'] = $gBitDbName;
     }
     parent::__construct();
     // Get all the ADODB stuff included
     if (!defined("ADODB_ASSOC_CASE")) {
         define("ADODB_ASSOC_CASE", 0);
     }
     if (!defined("ADODB_FETCH_MODE")) {
         define("ADODB_FETCH_MODE", ADODB_ASSOC_CASE);
     }
     $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
     if (!empty($pConnectionHash['db_name']) && !empty($pConnectionHash['db_type'])) {
         if ($pConnectionHash['db_type'] == 'oci8') {
             $pConnectionHash['db_type'] = 'oci8po';
         }
         $this->mType = $pConnectionHash['db_type'];
         $this->mName = $pConnectionHash['db_name'];
         if (!isset($this->mName)) {
             die("No database name specified");
         }
         $this->preDBConnection();
         $this->mDb = ADONewConnection($pConnectionHash['db_type']);
         $this->mDb->Connect($pConnectionHash['db_host'], $pConnectionHash['db_user'], $pConnectionHash['db_password'], $pConnectionHash['db_name']);
         if (!$this->mDb) {
             die("Unable to login to the database {$pConnectionHash['db_type']} on {$pConnectionHash['db_host']} as `user` {$pConnectionHash['db_user']}<p>" . $this->mDb->ErrorMsg());
         }
         $this->postDBConnection();
         unset($pDSN);
         if (defined("DB_PERFORMANCE_STATS") && constant("DB_PERFORMANCE_STATS")) {
             $this->mDb->LogSQL();
         }
     }
     $this->debug($this->getDebugLevel());
 }
Ejemplo n.º 2
0
 function __construct($pPearDsn = NULL, $pPearOptions = NULL)
 {
     global $gDebug;
     parent::__construct();
     if (empty($pPearDsn)) {
         global $gBitDbType, $gBitDbUser, $gBitDbPassword, $gBitDbHost, $gBitDbName;
         $pPearDsn = array('phptype' => $gBitDbType, 'username' => $gBitDbUser, 'password' => $gBitDbPassword, 'database' => $gBitDbHost . '/' . $gBitDbName);
     }
     if (empty($pPearOptions)) {
         $pPearOptions = array('debug' => 2, 'persistent' => false, 'portability' => DB_PORTABILITY_ALL);
     }
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'bit_pear_login_error');
     $this->mDb = DB::connect($pPearDsn, $pPearOptions);
     if (PEAR::isError($this->mDb)) {
         $this->mErrors['db_connect'] = $this->mDb->getDebugInfo();
     } else {
         $this->mDb->setFetchMode(DB_FETCHMODE_ASSOC);
         // Default to autocommit unless StartTrans is called
         $this->mDb->autoCommit(TRUE);
         $this->mType = $pPearDsn['phptype'];
         $this->mName = $pPearDsn['database'];
     }
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'bit_pear_error_handler');
 }