diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-03-21 10:54:47 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-03-21 10:54:47 -0600 |
commit | 2805ef7311eeb028cd48bffe04a705676c4682be (patch) | |
tree | 59c00c77d5bd59ea89967f18d5bcd6d1b5ad6e01 /model/Category.php | |
parent | f83530a122119d7f69812493f9c2f4987ccb2065 (diff) |
big changes pt1
Diffstat (limited to 'model/Category.php')
-rw-r--r-- | model/Category.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/model/Category.php b/model/Category.php new file mode 100644 index 0000000..d98b08b --- /dev/null +++ b/model/Category.php @@ -0,0 +1,36 @@ +<?php + +class Category { + public $id = 0; + public $name = 'Unknown'; + public $description = 'This category does not exist'; + public $thread_count = 0; + public $post_count = 0; + + function get_from_database($id, $dbc) { + $sql = "SELECT cat_name, cat_description, cat_thread_count, cat_post_count FROM categories WHERE cat_id = " . mysqli_real_escape_string($dbc, $id); + $result = mysqli_query($dbc, $sql); + + if (!$result) { + echo 'Failed to get category: ' . mysqli_error($dbc); + } + + if (mysqli_num_rows($result) == 0) { + echo 'Category does not exist!'; + } else { + while ($row = mysqli_fetch_assoc($result)) { + $this->id = $id; + $this->name = $row['cat_name']; + $this->description = $row['cat_description']; + $this->thread_count = $row['cat_thread_count']; + $this->post_count = $row['cat_post_count']; + } + } + + mysqli_free_result($result); + } + + function get_threads() { + + } +}
\ No newline at end of file |