コード例 #1
0
ファイル: Postgresql.php プロジェクト: edrdesigner/awf
 /**
  * Overloaded method which will create the database (if it doesn't exist).
  *
  * @return  Database\Driver
  */
 protected function getDatabase()
 {
     if (!is_object($this->db)) {
         $db = parent::getDatabase();
         try {
             $db->select($this->container['dbname']);
         } catch (\Exception $exc) {
             // We couldn't connect to the database. Maybe we have to create
             // it first. Let's see...
             $options = (object) array('db_name' => $this->container['dbname'], 'db_user' => $this->container['dbuser']);
             $db->createDatabase($options, true);
             $db->select($this->container['dbname']);
         }
     }
     return $this->db;
 }
コード例 #2
0
ファイル: Mysqli.php プロジェクト: edrdesigner/awf
 /**
  * Overloaded method which will create the database (if it doesn't exist).
  *
  * @return  Database\Driver
  */
 protected function getDatabase()
 {
     if (!is_object($this->db)) {
         $db = parent::getDatabase();
         try {
             $db->select($this->container['dbrestore']['dbname']);
         } catch (\Exception $exc) {
             // We couldn't connect to the database. Maybe we have to create
             // it first. Let's see...
             $options = (object) array('db_name' => $this->container['dbrestore']['dbname'], 'db_user' => $this->container['dbrestore']['dbuser']);
             $db->createDatabase($options, true);
             $db->select($this->container['dbrestore']['dbname']);
         }
         // Try to change the database collation, if requested
         if ($this->getParam('utf8db', 0)) {
             try {
                 $db->alterDbCharacterSet($this->container['dbrestore']['dbname']);
             } catch (\Exception $exc) {
                 // Ignore any errors
             }
         }
     }
     return $this->db;
 }