コード例 #1
0
ファイル: comment.php プロジェクト: toppestkek/GuestBook
<?php

$app->match('/comment/{id}', function ($id) use($app) {
    if (!isset($id) || $id <= 0) {
        $app->abort(404, "Comment {$id} does not exist.");
    }
    $main = '';
    $add = '';
    $pdo = new Db();
    $db = $pdo->get();
    $mapper = new Mapper($db);
    $comments = new Comments();
    $comments->id = $id;
    $data = $mapper->selectId($comments);
    if (empty($data)) {
        $app->abort(404, "Comment {$id} does not exist.");
    }
    if ($id == 1) {
        $first = 0;
    } else {
        $first = 1;
    }
    $all = count($mapper->select());
    if ($id == $all) {
        $last = 0;
    } else {
        $last = 1;
    }
    $next = $id + 1;
    $previous = $id - 1;
    $dir = '../';