public function __construct() { if (!isset(GManager::app()->config->db)) { throw new Exception('A configuração do banco não está definida'); } try { $dsn = GManager::app()->config->db->connectionString; $user = GManager::app()->config->db->user; $password = GManager::app()->config->db->password; $this->_pdo = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'GPDO - PDOException - Connection failed: ' . $e->getMessage(); } catch (Exception $e) { echo 'GPDO - Exception - Connection failed: ' . $e->getMessage(); } }
public static function init() { GManager::app()->config = json_decode(json_encode(require_once self::_path())); }