added notes page
This commit is contained in:
parent
c7882bc1a1
commit
3862b68d9f
27
Controller/NotesController.php
Normal file
27
Controller/NotesController.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace ppa\Controller;
|
||||
|
||||
use ppa\Model\NotesModel;
|
||||
use ppa\Library\View;
|
||||
|
||||
class NotesController
|
||||
{
|
||||
private $notesModel;
|
||||
protected $view;
|
||||
|
||||
public function __construct($view)
|
||||
{
|
||||
$this->notesModel = new NotesModel();
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function showNotes()
|
||||
{
|
||||
$this->view->setVars([
|
||||
"notes" => $this->notesModel->selectNotes()
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
29
Model/NotesModel.php
Normal file
29
Model/NotesModel.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace ppa\Model;
|
||||
use ppa\Model\ParticipantModel;
|
||||
|
||||
class NotesModel extends Database
|
||||
{
|
||||
public function selectNotes()
|
||||
{
|
||||
$sortBy = 'updated_at';
|
||||
$sortOrder = 'DESC';
|
||||
|
||||
$sql = "SELECT id, title, content, created_at, updated_at
|
||||
FROM notes
|
||||
WHERE user_id = 2
|
||||
ORDER BY updated_at DESC";
|
||||
|
||||
$pdo = $this->linkDB();
|
||||
|
||||
try {
|
||||
$res = $pdo->query($sql);
|
||||
} catch (\PDOException $e) {
|
||||
new \ppa\Library\ErrorMsg("Ihre Anfrage konnte nicht verarbeitet werden", $e);
|
||||
die;
|
||||
}
|
||||
|
||||
return $res->fetchAll(\PDO::FETCH_ASSOC);
|
||||
}
|
||||
}
|
17
Views/Notes/showNotes.phtml
Normal file
17
Views/Notes/showNotes.phtml
Normal file
@ -0,0 +1,17 @@
|
||||
<?php include dirname(__DIR__).'/header.phtml'; ?>
|
||||
|
||||
<h2>Notes</h2>
|
||||
|
||||
<div class="container">
|
||||
<?php
|
||||
|
||||
foreach($notes as $n) {
|
||||
echo '<div class="item-4-12">';
|
||||
echo '<h3>' . $n["title"] . '</h3>'
|
||||
. '<p>' . $n["content"] . '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php include dirname(__DIR__).'/footer.phtml'; ?>
|
Loading…
x
Reference in New Issue
Block a user