diff options
Diffstat (limited to 'includes/model/Thread.php')
-rw-r--r-- | includes/model/Thread.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/includes/model/Thread.php b/includes/model/Thread.php index c939738..2a74a0e 100644 --- a/includes/model/Thread.php +++ b/includes/model/Thread.php @@ -11,8 +11,8 @@ class Thread public $subject; public $date_created = 0; public $last_post_date = 0; - public $category; - public $author; + public $category_id; + public $author_id; private $has_value = false; @@ -29,10 +29,8 @@ class Thread $this->subject = $result[0]['thread_subject']; $this->date_created = $result[0]['thread_date_created']; $this->last_post_date = $result[0]['thread_last_post_date']; - $this->category = new Category($result[0]['thread_category']); - - $this->author = new User(); - $this->author->get_by_id($result[0]['thread_author']); + $this->category_id = $result[0]['thread_category']; + $this->author_id = $result[0]['thread_author']; $this->has_value = true; } @@ -79,7 +77,7 @@ class Thread Database::get()->query("DELETE FROM threads WHERE thread_id = ?", "i", $thread->id); // Decrement the thread count of the category - Database::get()->query("UPDATE categories SET `category_thread_count` = `category_thread_count` - '1' WHERE category_id = ?", "i", $thread->category->id); + Database::get()->query("UPDATE categories SET `category_thread_count` = `category_thread_count` - '1' WHERE category_id = ?", "i", $thread->category_id); } public function has_value(): bool @@ -87,6 +85,18 @@ class Thread return $this->has_value; } + public function get_parent_category(): ?Category + { + return new Category($this->category_id); + } + + public function get_author(): ?User + { + $result = new User(); + $result->get_by_id($this->author_id); + return $result; + } + public static function get_all(): array { $sql = "SELECT thread_id FROM threads"; |