diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-08-10 16:17:53 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-08-10 16:17:53 -0600 |
commit | 5d703ab4ea6e8ead889232ba846596b948bdb051 (patch) | |
tree | 8ef9327db50cf9cefbf92c96ac3979bc1bd32542 /includes/model/Thread.php | |
parent | 04d30cfe16e11140c8efb22afd61f2386c35cd87 (diff) |
Update names of database variables
Diffstat (limited to 'includes/model/Thread.php')
-rw-r--r-- | includes/model/Thread.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/includes/model/Thread.php b/includes/model/Thread.php index 628a325..c939738 100644 --- a/includes/model/Thread.php +++ b/includes/model/Thread.php @@ -10,7 +10,7 @@ class Thread public $id; public $subject; public $date_created = 0; - public $date_lastpost = 0; + public $last_post_date = 0; public $category; public $author; @@ -18,7 +18,7 @@ class Thread function __construct($id) { - $sql = "SELECT thread_subject, thread_date_created, thread_date_lastpost, thread_category, thread_author FROM threads WHERE thread_id = ?;"; + $sql = "SELECT thread_subject, thread_date_created, thread_last_post_date, thread_category, thread_author FROM threads WHERE thread_id = ?;"; $result = Database::get()->query($sql, "i", $id); if (empty($result)) { @@ -28,7 +28,7 @@ class Thread $this->id = $id; $this->subject = $result[0]['thread_subject']; $this->date_created = $result[0]['thread_date_created']; - $this->date_lastpost = $result[0]['thread_date_lastpost']; + $this->last_post_date = $result[0]['thread_last_post_date']; $this->category = new Category($result[0]['thread_category']); $this->author = new User(); @@ -47,14 +47,14 @@ class Thread $user = Session::get()->get_current_user(); // Insert the new thread into the database - $sql = "INSERT INTO threads(thread_subject, thread_date_created, thread_date_lastpost, thread_category, thread_author) VALUES (?, CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), ?, ?);"; + $sql = "INSERT INTO threads(thread_subject, thread_date_created, thread_last_post_date, thread_category, thread_author) VALUES (?, CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), CONVERT_TZ(NOW(), 'SYSTEM', '+00:00'), ?, ?);"; Database::get()->query($sql, "sii", $subject, $category, $user->id); // Get the ID of the thread we just created $thread_id = Database::get()->get_last_id(); // Increment the category's thread count - $sql = "UPDATE categories SET `cat_thread_count` = `cat_thread_count` + '1' WHERE cat_id = ?;"; + $sql = "UPDATE categories SET `category_thread_count` = `category_thread_count` + '1' WHERE category_id = ?;"; Database::get()->query($sql, "i", $category); return $thread_id; @@ -79,11 +79,11 @@ 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 `cat_thread_count` = `cat_thread_count` - '1' WHERE cat_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 - { + { return $this->has_value; } @@ -105,7 +105,7 @@ class Thread public static function get_latest(): array { - $sql = "SELECT thread_id FROM threads ORDER BY thread_date_lastpost DESC LIMIT 10"; + $sql = "SELECT thread_id FROM threads ORDER BY thread_last_post_date DESC LIMIT 10"; $result = Database::get()->query($sql); $threads = array(); |