@@ -22,7 +22,7 @@ Thread | |||||
LEFT OUTER JOIN | LEFT OUTER JOIN | ||||
responses AS r | responses AS r | ||||
ON | ON | ||||
r.threads_id = t.id | |||||
r.thread_id = t.id | |||||
WHERE | WHERE | ||||
t.id <> 1 | t.id <> 1 | ||||
-- AND t.deleted = 0 | -- AND t.deleted = 0 | ||||
@@ -56,7 +56,28 @@ Thread | |||||
int $id) | int $id) | ||||
: \Dto\Thread | : \Dto\Thread | ||||
{ | { | ||||
; | |||||
// TODO: 書くこと | |||||
$sql = " | |||||
SELECT | |||||
t.id, | |||||
t.title, | |||||
t.explain, | |||||
MAX(r.date) AS latest | |||||
FROM | |||||
threads AS t | |||||
LEFT OUTER JOIN | |||||
responses AS r | |||||
ON | |||||
r.thread_id = t.id | |||||
WHERE | |||||
t.id = $id | |||||
GROUP BY | |||||
t.id | |||||
ORDER BY | |||||
latest DESC"; | |||||
$result = $db -> query ($sql); | |||||
} | } | ||||