コード例 #1
0
ファイル: WeatherModel.php プロジェクト: e-lev777/weather
 public function getInformerData()
 {
     /** @var PDO $dbh */
     $dbh = Registry::get('dbh');
     /** statement handler */
     $sth = $dbh->prepare("SELECT content FROM informer");
     $sth->execute();
     return $sth->fetch(PDO::FETCH_ASSOC);
 }
コード例 #2
0
ファイル: index.php プロジェクト: e-lev777/weather
$url = explode('?', $_SERVER['REQUEST_URI']);
$url = $url[0];
//функуия автозагрузки
function __autoload($classname)
{
    $classFile = str_replace('\\', '/', $classname);
    if (file_exists(ROOT . $classFile . '.php')) {
        require ROOT . $classFile . '.php';
    } else {
        throw new Exception("{$classFile} not found");
    }
}
try {
    $dbh = new PDO($dsn, $user, $password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    Registry::set('dbh', $dbh);
    Router::resolve($url);
    $_controller = Router::$_controller;
    $_action = Router::$_action;
    $_controller = '\\Controller\\' . ucfirst($_controller) . "Controller";
    $_action .= "Action";
    $_controller = new $_controller();
    if (method_exists($_controller, $_action)) {
        $content = $_controller->{$_action}();
    } else {
        throw new Exception("{$_action} not found");
    }
} catch (PDOException $e) {
    $to = $for_pdo_exception['email'];
    $subject = $for_pdo_exception['subject'];
    $message = $e->getMessage();