예제 #1
0
파일: PI.php 프로젝트: stdakov/pi_framework
 public function initConfig()
 {
     $this->config = \App\Core\Config::getInstance();
     $this->config->init(CONFIG_INI);
     $this->config->loadConfig(CONFIG_DIR);
     $this->config->loadHelpers(HELPER_DIR);
 }
예제 #2
0
 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());
         }
     }
 }