コード例 #1
0
ファイル: Mdb2Connection.php プロジェクト: Trideon/gigolo
 public function Connect()
 {
     if ($this->_connected && !is_null($this->_db)) {
         return;
     }
     $dsn = array('phptype' => $this->_dbType, 'username' => $this->_dbUser, 'password' => $this->_dbPassword, 'hostspec' => $this->_hostSpec, 'database' => $this->_dbName);
     $options = array('debug' => 0, 'portability' => MDB2_PORTABILITY_ALL, 'persistent' => true);
     $this->_db =& MDB2::connect($dsn, $options);
     if (MDB2::isError($this->_db)) {
         // If there is an error, print to browser, print to logfile and kill app
         throw new Exception("Error connecting to database\nError: " . $this->_db->getMessage() . "\nDebug: " . $this->_db->getDebugInfo());
         // TODO: LOG
     }
     $this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC);
     // Set fetch mode to return associatve array
     $this->_connected = true;
 }