/** * Establishes the connection to the database * * This methods establishes the default connection to the database by using * configuration parameters that come from the basis configuration object * and then, register the {@link EasySCP_Database} instance in the * {@link EasySCP_Registry} for shared access. * * A PDO instance is also registered in the registry for shared access. * * @throws EasySCP_Exception * * @return void * @todo Remove global variable */ protected function _initializeDatabase() { try { $connection = EasySCP_Database::connect($this->_config->DATABASE_USER, decrypt_db_password($this->_config->DATABASE_PASSWORD), $this->_config->DATABASE_TYPE, $this->_config->DATABASE_HOST, $this->_config->DATABASE_NAME); } catch (PDOException $e) { throw new EasySCP_Exception('Error: Unable to establish connection to the database! ' . 'SQL returned: ' . $e->getMessage()); } // Register both Database and PDO instances for shared access EasySCP_Registry::set('Db', $connection); EasySCP_Registry::set('Pdo', EasySCP_Database::getRawInstance()); // @todo remove the Global $GLOBALS['sql'] = EasySCP_Registry::get('Db'); }