/** * 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; }
public function step() { $key = $this->input->get('key', null); $model = AModel::getAnInstance('Database', 'AngieModel'); $data = $model->getDatabaseInfo($key); try { $restoreEngine = ADatabaseRestore::getInstance($key, $data); $result = $restoreEngine->stepRestoration(); } catch (Exception $exc) { $result = array('percent' => 0, 'restored' => 0, 'total' => 0, 'eta' => 0, 'error' => $exc->getMessage(), 'done' => 1); } echo json_encode($result); }
/** * 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; }