Exemplo n.º 1
0
namespace SQL3;

include_once 'CommentRepository.php';
include_once 'ForumRepository.php';
$forumrep = new ForumRepository();
$commentrep = new CommentRepository();
$forums = $forumrep->getAll();
echo "<h1> Forums </h1>";
echo "<ul>";
foreach ($forums as $forum) {
    echo "<li>";
    echo "<b>ID:</b>" . $forum->getId() . "   ";
    echo "<b>Name:</b>" . $forum->getTheme() . "   ";
    echo "<b>Post Date:</b>" . $forum->getDate() . "   ";
    echo "<b>Comment Count:</b>" . $forum->getCommentCount() . "   ";
    echo "<h4> Comments: </h4>";
    echo "<ul>";
    $comments = $commentrep->getAllByForumId($forum->getId());
    foreach ($comments as $comment) {
        echo "<li>";
        echo "<b>ID:</b>" . $comment->getId() . "  ";
        echo "<b>Author:</b>" . $comment->getAuthor() . "  ";
        echo "<b>Date commented:</b>" . $comment->getDate() . "  ";
        echo "<div>" . $comment->getString() . "</div>";
        echo "</li>";
        echo "<br>";
    }
    echo "</ul>";
    echo "</li>";
}
echo "</ul>";