Esempio n. 1
0
<?php

$BlogsController = new BlogsController($db, $plural_resource, $action);
$blog_record = $BlogsController->show($id);
$blog = mysqli_fetch_assoc($blog_record);
?>

<h2>記事詳細</h2>
<div><?php 
echo $blog['title'];
?>
</div>
<div><?php 
echo $blog['body'];
?>
</div>

<?php 
echo '<a href="../index">一覧へ</a>';
Esempio n. 2
0
<?php

require 'models/blog.php';
$controller = new BlogsController();
//アクション名によって、呼び出すメソッドを変える
//$action(グローバル変数)は、routes.phpで定義されているもの
switch ($action) {
    case 'index':
        $controller->index();
        break;
    case 'show':
        $controller->show($id);
        break;
    case 'add':
        $controller->add();
        break;
    case 'create':
        $controller->create($post['title'], $post['body']);
        break;
    case 'edit':
        $controller->edit($id);
        break;
    case 'update':
        $controller->update($id, $post['title'], $post['body']);
        break;
    case 'delete':
        $controller->delete($id);
        break;
    default:
        break;
}
Esempio n. 3
0
<?php

// BlogsControllerのshowを呼び出す
$BlogsController = new BlogsController($db, $plural_resorce, $option);
$blogs = $BlogsController->show();
while ($blog = mysqli_fetch_assoc($blogs)) {
    $title = $blog['title'];
    $body = $blog['body'];
    $created = $blog['created'];
    // 処理したデータ等を表示する(view)
    echo "====================<br>";
    echo $title;
    echo "<br>";
    echo $body;
    echo "<br>";
    echo $created;
    echo "<br>";
}