/** * Инициализация объекта контроллера действий, заполнение свойств. */ public function __construct() { $this->view = new View(); $this->config = ApplicationRegistry::instance(); $this->request = RequestRegistry::instance(); $this->session = SessionRegistry::instance(); }
/** * Устанавливает соединение с базой данных. * * @throws \REXFramework\exceptions\AppException */ public function __construct() { if (!isset(self::$PDO)) { try { $config = \REXFramework\registry\ApplicationRegistry::instance()->getConfigParam('DBConnection'); $dsn = 'mysql:dbname=' . $config['db_name'] . ';host=' . $config['db_host']; self::$PDO = new \PDO($dsn, $config['db_user'], $config['db_password']); self::$PDO->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); self::$PDO->query("SET names 'utf8'"); } catch (\PDOException $e) { throw new AppException($e->getMessage()); } } }
/** * Закрытый конструктор * Получает конфигурацию, создает объект */ private function __construct() { $config = ApplicationRegistry::instance(); $this->config = $config->getConfigParam('Mail'); }