キケッツ掲示板のリポジトリです. https://bbs.kekec.wiki
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
904 B

  1. <?php
  2. namespace Dao;
  3. class
  4. Thread
  5. {
  6. public function
  7. get_threads (
  8. SQLite3 $db)
  9. : array
  10. {
  11. $sql = "
  12. SELECT
  13. t.id,
  14. t.title,
  15. t.explain,
  16. MAX(r.date) AS latest
  17. FROM
  18. threads AS t
  19. LEFT OUTER JOIN
  20. responses AS r
  21. ON
  22. r.threads_id = t.id
  23. WHERE
  24. t.id <> 1
  25. -- AND t.deleted = 0
  26. GROUP BY
  27. t.id
  28. ORDER BY
  29. latest DESC";
  30. $result = $db -> query ($sql);
  31. $threads = [];
  32. while (($row = $threads -> fetchArray (SQLITE3_ASSOC)) !== false)
  33. {
  34. $thread = new Dto\Thread;
  35. $thread -> id = $row['id'];
  36. $therad -> title = $row['title'];
  37. $thread -> explain = $row['explain'];
  38. $thread -> latest = $row['latest'];
  39. $threads[] = $thread;
  40. }
  41. return $therads;
  42. }
  43. }