public static function configs($filename) { if (file_exists(CONFIGS . $filename . ".php")) { return include CONFIGS . $filename . ".php"; } elseif (file_exists(CONFIGS . ENVIRONMENT . '/' . $filename . ".php")) { return include CONFIGS . ENVIRONMENT . '/' . $filename . ".php"; } throw new Exception(Tradutor::translate("Unable to load file ") . $filename); }
/** * Método para resgatar a mensagem do erro ocorrido: */ public function getError() { $error = Tradutor::translate('Melyssa Exception') . ': '; $error .= '<strong>' . $this->message . '</strong>'; $error .= ' ' . Tradutor::translate('on file') . ': '; $error .= '<strong>' . $this->file . '</strong> '; $error .= Tradutor::translate('at line') . ': <strong>' . $this->line . '</strong>.<br><br>'; die($error); }
/** * Initialize * * Se já houver uma conexão com o banco de dados aberta, retorna, caso contrário, * cria uma nova conexão e retorna; * * @return Object PDO instance * @throws Melyssa\Exception */ private function initialize() { // Carregando as configurações de dentro da pasta: $configs = Loader::configs("Database"); if (isset($configs['dsn'], $configs['username'], $configs['password'])) { // Temos as configurações, podemos instanciar a PDO: try { self::$connection = new \PDO($configs['dsn'], $configs['username'], $configs['password']); } catch (\PDOException $pe) { echo $pe->getMessage(); } } else { throw new Exception(Tradutor::translate("Invalid database configuration")); } }