Esempio n. 1
0
 public function __construct()
 {
     $paramsPath = ROOT . '/config/db_params.php';
     $params = (include $paramsPath);
     $dsn = "mysql:host={$params['host']};dbname={$params['dbname']}";
     try {
         $this->db = new PDO($dsn, $params['user'], $params['password']);
         $this->db->exec("SET NAMES 'utf-8'");
     } catch (PDOException $e) {
         $logger = Logger::getInstance();
         $logger->setLog($e->getFile(), $e->getLine(), $e->getMessage());
         $view = new View();
         $view->error = "Нет соединения с БД";
         $view->display('error.php');
         die;
     }
 }
Esempio n. 2
0
<?php

use App\Components\Router;
use App\Components\View;
use App\Components\Logger;
use App\Components\FunctionLibrary as FL;
// Front Controller
// 1. Общие настройки
ini_set('display_errors', 1);
error_reporting(E_ALL);
session_start();
// 2. Подключение системных файлов
define('ROOT', dirname(__FILE__));
require_once ROOT . '/components/autoload.php';
// 3. Вызов Router
try {
    $router = new Router();
    $router->run();
    FL::deleteLink();
} catch (Exception $e) {
    $logger = Logger::getInstance();
    $logger->setLog($e->getFile(), $e->getLine(), $e->getMessage());
    $view = new View();
    $view->error = $e->getMessage();
    $view->display('error.php');
}