/** * Overloaded method which will create the database (if it doesn't exist). * * @return ADatabaseDriver */ protected function getDatabase() { if (!is_object($this->db)) { $db = parent::getDatabase(); $db->setUtf8Mb4AutoDetection($this->dbiniValues['utf8mb4']); try { $db->select($this->dbiniValues['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->dbiniValues['dbname'], 'db_user' => $this->dbiniValues['dbuser']); $db->createDatabase($options, true); $db->select($this->dbiniValues['dbname']); } // Try to change the database collation, if requested if ($this->dbiniValues['utf8db']) { try { $db->alterDbCharacterSet($this->dbiniValues['dbname']); } catch (Exception $exc) { // Ignore any errors } } } return $this->db; }
/** * Overloaded method which will create the database (if it doesn't exist). * * @return ADatabaseDriver */ protected function getDatabase() { if (!is_object($this->db)) { $db = parent::getDatabase(); try { $x = $db->select($this->dbiniValues['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->dbiniValues['dbname'], 'db_user' => $this->dbiniValues['dbuser']); $db->createDatabase($options, true); $db->select($this->dbiniValues['dbname']); } } return $this->db; }