From 7ef208fc1ae5a24d7b3cd2e22e969285fbf7262a Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Sun, 21 Mar 2021 17:29:58 -0600 Subject: Add additional classes and functions --- model/User.php | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 model/User.php (limited to 'model/User.php') diff --git a/model/User.php b/model/User.php new file mode 100644 index 0000000..89a14a5 --- /dev/null +++ b/model/User.php @@ -0,0 +1,54 @@ +id = $row['user_id']; + $this->name = $name; + $this->date = $row['user_date']; + } + } + + mysqli_free_result($result); + mysqli_stmt_close($stmt); + } + + function get_by_id($id, $dbc) { + $sql = "SELECT user_name, user_date FROM users WHERE user_id = " . mysqli_real_escape_string($dbc, $id); + $result = mysqli_query($dbc, $sql); + + if (!$result) { + echo 'Failed to get user: ' . mysqli_error($dbc); + } + + if (mysqli_num_rows($result) == 0) { + } else { + while ($row = mysqli_fetch_assoc($result)) { + $this->id = $id; + $this->name = $row['user_name']; + $this->date = $row['user_date']; + } + } + + mysqli_free_result($result); + } + +} \ No newline at end of file -- cgit v1.2.3