コード例 #1
0
ファイル: restore.php プロジェクト: WineWorld/joomlatrialcmbg
 /**
  * Returns the instance of the database driver, creating it if it doesn't
  * exist.
  *
  * @return  ADatabaseDriver
  *
  * @throws RuntimeException
  */
 protected function getDatabase()
 {
     if (!is_object($this->db)) {
         $options = array('driver' => $this->dbiniValues['dbtype'], 'database' => $this->dbiniValues['dbname'], 'select' => 0, 'host' => $this->dbiniValues['dbhost'], 'user' => $this->dbiniValues['dbuser'], 'password' => $this->dbiniValues['dbpass'], 'prefix' => $this->dbiniValues['prefix']);
         $class = 'ADatabaseDriver' . ucfirst(strtolower($options['driver']));
         try {
             $this->db = new $class($options);
             $this->db->setUTF();
         } catch (RuntimeException $e) {
             throw new RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
         }
     }
     return $this->db;
 }