Esempio n. 1
0
 public function __construct($iniConfigurationFilepath)
 {
     $config = Library::parse_ini_file_advanced($iniConfigurationFilepath);
     $this->config = $config[APPLICATION_ENV];
     $this->route = new Route();
     $this->request = new Request();
     $this->_loadPHPSettings();
     if (php_sapi_name() !== 'cli') {
         $this->route->setCurrentUrl($_SERVER['REQUEST_URI']);
     }
     $baseUrl = rtrim('/' . trim($this->config['general.baseUrl'], '/'), '/');
     $url = str_replace($baseUrl, '', $this->route->getCurrentUrl());
     Registry::set('config', $this->config);
     Registry::set('route', $this->route);
     Registry::set('request', $this->request);
     $this->route->setDefaultModule($this->config['general.defaultModule'])->setDefaultController($this->config['general.defaultController'])->setDefaultAction($this->config['general.defaultAction'])->setDefaultLayout($this->config['general.defaultLayout'])->setBaseUrl($baseUrl)->dispatchFromURL($url);
 }
Esempio n. 2
0
 private function _run()
 {
     if (null === $this->sql) {
         return null;
     }
     if ($this->_cached) {
         $result = Registry::get('sql:' . $this->sql);
         if ($result) {
             return $result;
         }
     }
     try {
         $this->stmt = $this->conn->prepare($this->sql);
         $this->stmt->execute();
     } catch (\PDOException $e) {
         throw new Exception($e);
     }
     if (null === $this->stmt) {
         return null;
     }
     $result = $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
     if ($this->_cached) {
         Registry::set('sql:' . $this->sql, $result);
     }
     return $result;
 }