query($sql, "i", $id); if (empty($result)) { return false; } $this->id = $id; $this->name = $result[0]['cat_name']; $this->description = $result[0]['cat_description']; $this->thread_count = $result[0]['cat_thread_count']; $this->post_count = $result[0]['cat_post_count']; return true; } function get_threads(): array { $sql = "SELECT thread_id FROM threads WHERE thread_category = ? ORDER BY thread_date_lastpost DESC"; $result = Database::get()->query($sql, "i", $this->id); $threads = array(); foreach ($result as $row) { $thread = new Thread(); $thread->get_from_database($row['thread_id']); array_push($threads, $thread); } return $threads; } function get_latest_thread(): Thread { $sql = "SELECT thread_id FROM threads WHERE thread_category = ? ORDER BY thread_date_lastpost DESC LIMIT 1"; $result = Database::get()->query($sql, "i", $this->id); $thread = new Thread(); $thread->get_from_database($result[0]['thread_id']); return $thread; } }