From e7e237dacaf7bbaa739c7e9a430958aed09aa647 Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 24 Dec 2024 00:13:29 +0000 Subject: add interaction buttons (they dont do anything) --- Digitigrade/Model.php | 6 +++++- Digitigrade/Model/Note.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Digitigrade') diff --git a/Digitigrade/Model.php b/Digitigrade/Model.php index dca1484..4a206a6 100644 --- a/Digitigrade/Model.php +++ b/Digitigrade/Model.php @@ -157,13 +157,17 @@ abstract class Model { string $whereClause, array $parameters, ?int $limit = null, - int $offset = 0 + int $offset = 0, + ?string $orderByClause = null ): array { $classNameParts = explode('\\', static::class); $className = $classNameParts[count($classNameParts) - 1]; $tableName = self::mangleName($className); $query = "SELECT * FROM $tableName WHERE $whereClause"; + if ($orderByClause != null) { + $query .= " ORDER BY $orderByClause"; + } if ($limit != null) { $query .= " LIMIT $limit OFFSET $offset"; } diff --git a/Digitigrade/Model/Note.php b/Digitigrade/Model/Note.php index 37ddff3..3c0c690 100644 --- a/Digitigrade/Model/Note.php +++ b/Digitigrade/Model/Note.php @@ -103,7 +103,7 @@ class Note extends PushableModel { } public static function findAllWithAuthor(Actor $author, ?int $limit = null, int $offset = 0): array { - return self::findAllWhere('author = ?', [$author->id], $limit, $offset); + return self::findAllWhere('author = ?', [$author->id], $limit, $offset, 'created DESC'); } public function getInteractions(): array { -- cgit v1.3