示例#1
0
<?php

namespace ActiveRecord;

require_once "Tema.php";
echo "<a href='generuoti.php'>Generuoti duomenis</a>";
$tema = new Tema();
$res = $tema->getAll(true);
if ($res['status'] == 'failed') {
    echo "<h1>Sorry, something went wrong</h1>";
    echo "<p>Message: " . $res['message'] . "</p>";
    return;
}
$temos = $res['data'];
//isvesk temas
echo "<table width='100%' border='1'>\n    <tr>\n    <th align='left'>Data</th>\n    <th align='left'>Pavadinimas</th>\n    <th align='left'>komentaru skaicius</th>\n    <th align='left'>komentarai</th>\n    </tr>\n";
if (empty($temos)) {
    echo "<tr><td colspan='4'>Įrašų nėra</td></tr>";
}
foreach ($temos as $tema) {
    echo "<tr>\n        <td>" . $tema->getData() . "</td>\n        <td>" . $tema->getPavadinimas() . "</td>\n        <td>" . $tema->getKomentaruSkaicius() . "</td>\n        <td>";
    foreach ($tema->getKomentarai() as $komentaras) {
        echo $komentaras->getData() . ' ' . $komentaras->getKomentaras() . ' ' . $komentaras->getAutorius() . "<br />";
    }
    echo "</td>\n        </tr>\n    ";
}
echo "</table>";