somewhat functional notes table (needs improvement)

This commit is contained in:
Felix Ivo
2025-06-16 10:21:41 +02:00
parent 8c13989d47
commit b6d51cbc37
3 changed files with 69 additions and 19 deletions

View File

@@ -5,15 +5,12 @@ use ppa\Model\ParticipantModel;
class NotesModel extends Database
{
public function selectNotes()
public function selectNotesForUser($userid, $sortBy = 'updated_at', $sortOrder = 'DESC')
{
$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";
$sql = "SELECT n.*, u.username AS owner_username
FROM notes n
JOIN users u ON n.user_id = u.id
ORDER BY {$sortBy} {$sortOrder}";
$pdo = $this->linkDB();