Example #1
0
<?php

namespace Akademija\DDD;

include_once 'Theme.php';
include_once 'ThemeRepository.php';
include_once 'Comment.php';
include_once 'CommentRepository.php';
include_once 'dbConnection.php';
$db = new dbConnection('localhost', 'root', '', 'akademija-nd');
$db = $db->connect();
$themesRepository = new ThemeRepository($db);
$commentsRepository = new CommentRepository($db);
$themes = $themesRepository->loadAll();
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Domain Driven Design</title>
</head>
<body>

<?php 
foreach ($themes as $theme) {
    echo '<b>Tema:</b> ' . $theme->getTitle() . '<br> <b>Data:</b> ' . $theme->getDate() . '<br> <b>Komentaru skaicius:</b> ' . $theme->getCommentCount() . '<br><br>';
    echo '
        <form  action="Add.php" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="themeId" value="' . $theme->getId() . '">
        <b>Vardas:</b><br>
Example #2
0
<?php

namespace Akademija\DDD;

include_once 'Theme.php';
include_once 'ThemeRepository.php';
include_once 'Comment.php';
include_once 'dbConnection.php';
if (isset($_POST["themeId"])) {
    $db = new dbConnection('localhost', 'root', '', 'akademija-nd');
    $db = $db->connect();
    $themesRepository = new ThemeRepository($db);
    $themeId = (int) $_POST["themeId"];
    $comment = new Comment();
    $comment->setThemeId($themeId);
    $comment->setDate(date("Y-m-d H:i:s"));
    $comment->setAuthor($_POST["author"]);
    $comment->setComment($_POST["comment"]);
    $themesRepository->addComment($comment);
    echo "<h2>Komentaras pridetas!</h2>";
} else {
    echo "<h2>Klaida!</h2>";
}
//header( "Refresh:15; url=List.php", true, 303);
echo '<a href="List.php"><- Atgal</a>';