Пример #1
0
 function connect($Database = "", $Host = "", $User = "", $Password = "")
 {
     /* Handle defaults */
     if ("" == $Database) {
         $Database = $this->Database;
     }
     if ("" == $Host) {
         $Host = $this->Host;
     }
     if ("" == $User) {
         $User = $this->User;
     }
     if ("" == $Password) {
         $Password = $this->Password;
     }
     # Ben Drushell - added Oci8PutEnv for consistancy with db_oracle
     if ($this->Oci8PutEnv) {
         PutEnv("ORACLE_SID={$this->Database}");
         PutEnv("ORACLE_HOME={$this->Host}");
     }
     if (0 == $this->Link_ID) {
         if ($this->Debug) {
             printf("<br>Connecting to {$this->Database}...<br>\n");
         }
         $this->Link_ID = OCIplogon("{$this->User}", "{$this->Password}", "{$this->Database}");
         if (!$this->Link_ID) {
             $this->halt("Link-ID == false " . "({$this->Link_ID}), OCILogon failed");
         }
         if ($this->Debug) {
             printf("<br>Obtained the Link_ID: {$this->Link_ID}<br>\n");
         }
     }
     return $this->Link_ID;
 }
Пример #2
0
 function connect()
 {
     if (!$this->Connected) {
         $this->Query_ID = 0;
         if ($this->Debug) {
             printf("<br>Connecting to {$this->DBDatabase}...<br>\n");
         }
         $old_error_reporting = error_reporting();
         error_reporting($old_error_reporting & ~E_WARNING);
         if ($this->Persistent) {
             $this->Link_ID = OCIplogon("{$this->DBUser}", "{$this->DBPassword}", "{$this->DBDatabase}", $this->Encoding);
         } else {
             $this->Link_ID = OCIlogon("{$this->DBUser}", "{$this->DBPassword}", "{$this->DBDatabase}", $this->Encoding);
         }
         error_reporting($old_error_reporting);
         if (!$this->Link_ID) {
             $this->Error = OCIError();
             $this->Halt($this->Error);
             #$this->Halt("Cannot connect to Database: " . $this->Error["message"]. " ". $this->Error);
             return 0;
         }
         if ($this->Debug) {
             printf("<br>Obtained the Link_ID: {$this->Link_ID}<br>\n");
         }
         $this->Connected = true;
     }
     return $this->Connected;
 }
Пример #3
0
 function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
 {
     if ($argHostname) {
         // added by Jorma Tuomainen <*****@*****.**>
         if (strpos($argHostname, ":")) {
             $argHostinfo = explode(":", $argHostname);
             $argHostname = $argHostinfo[0];
             $argHostport = $argHostinfo[1];
         } else {
             $argHostport = "1521";
         }
         $argDatabasename = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" . $argHostname . ")(PORT=" . $argHostport . "))(CONNECT_DATA=(SERVICE_NAME=" . $argDatabasename . ")))";
     }
     $this->_connectionID = OCIplogon($argUsername, $argPassword, $argDatabasename);
     if ($this->_connectionID === false) {
         return false;
     }
     if ($this->_initdate) {
         $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
     }
     return true;
 }