From efa4ceedf8b2244afa4a91ac3f1bda1fbec00d56 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Wed, 7 Feb 2024 04:13:28 +0900 Subject: [PATCH] =?UTF-8?q?DAO=20=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- daos/thread.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ dtos/thread.php | 9 +++++---- 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 daos/thread.php diff --git a/daos/thread.php b/daos/thread.php new file mode 100644 index 0000000..dd8c0d8 --- /dev/null +++ b/daos/thread.php @@ -0,0 +1,53 @@ + 1 + -- AND t.deleted = 0 + GROUP BY + t.id + ORDER BY + latest DESC"; + + $result = $db -> query ($sql); + + $threads = []; + + while (($row = $threads -> fetchArray (SQLITE3_ASSOC)) !== false) + { + $thread = new Dto\Thread; + + $thread -> id = $row['id']; + $therad -> title = $row['title']; + $thread -> explain = $row['explain']; + $thread -> latest = $row['latest']; + + $threads[] = $thread; + } + + return $therads; + } +} + diff --git a/dtos/thread.php b/dtos/thread.php index 7e8624e..33b4839 100644 --- a/dtos/thread.php +++ b/dtos/thread.php @@ -6,9 +6,10 @@ namespace Dto; class Thread { - public int $id; - public string $title; - public ?string $explain; - public bool $deleted; + public int $id; + public string $title; + public ?string $explain; + public ?DateTime $latest; + public bool $deleted; }