public function initConfig() { $this->config = \App\Core\Config::getInstance(); $this->config->init(CONFIG_INI); $this->config->loadConfig(CONFIG_DIR); $this->config->loadHelpers(HELPER_DIR); }
public function __construct() { // Define PDO instance if ($this->pdo === null) { try { $config = Config::getInstance(); $dbConfig = $config->load('app')->get("database"); $this->pdo = new PDO('mysql:dbname=' . $dbConfig['DB_DATABASE'] . ';host=' . $dbConfig['DB_HOST'], $dbConfig['DB_USERNAME'], $dbConfig['DB_PASSWORD']); // Set default fetch mode $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); // Set MySQL specific attributes if ($this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') { $this->pdo->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES utf8"); } } catch (\PDOException $exception) { throw new \Exception($exception->getMessage()); } } }