public function __construct() { $this->default_handler = Option::None(); $this->route = HttpRoute::getInstance(); Event::addEventListener(self::EVENT_DYNAMIC_ROUTER_INIT, $this); }
<?php /** * Database configuration file * * Created by PhpStorm * User: roman * Date: 16.07.15 * Time: 20:17 */ use app\core\db\DatabaseConfiguration; use app\core\etc\Settings; use app\core\modular\Event; Event::addFilter("database.configure", function (DatabaseConfiguration $config) { $settings = Settings::getInstance(); $config->setDsnLogin($settings->get("pdo", "login")); $config->setDsnPassword($settings->get("pdo", "password")); $config->setDsnUri($settings->get("pdo", "dsn")); return $config; });
/** * @param $query * @param $params * @throws ApplicationException * @return \PDOStatement */ private function createResource($query, $params = null) { $queryString = $this->queryQuote($query, $params); Logger::printf($queryString); /** * @var PDOStatement $resource */ $resource = Event::applyFilters("database.pdo.statement.prepare", $this->pdo->prepare($queryString)); if ($resource === false) { throw new ApplicationException($this->pdo->errorInfo()[2]); } $resource->execute(); Event::callEventListeners("database.pdo.statement.executed", $resource); if ($resource->errorCode() !== "00000") { throw new ApplicationException($resource->errorInfo()[2]); } return $resource; }