From bdf5c221a7026fcd4e9a4477664e41bb776d37e1 Mon Sep 17 00:00:00 2001 From: "K. Nobel" Date: Wed, 18 Jan 2017 14:23:36 +0100 Subject: [PATCH] Added queries related to users. --- website/queries/user.php | 72 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 website/queries/user.php diff --git a/website/queries/user.php b/website/queries/user.php new file mode 100644 index 0000000..a73c16c --- /dev/null +++ b/website/queries/user.php @@ -0,0 +1,72 @@ +prepare(" + SELECT + `username`, + IFNULL( + `profilepicture`, + 'img/notbad.png' + ) AS profilepicture, + `bio`, + `role`, + `onlinestatus`, + `loggedin`, + `fname`, + `lname` + FROM + `user` + WHERE + `userID` = :userID + "); + + $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetch(); +} + +function selectAllUserGroups($db, $userID) { + $stmt = $db->prepare(" + SELECT + `group_page`.`groupID`, + `name`, + `picture`, + `userID` + FROM + `group_page` + INNER JOIN + `group_member` + ON + `group_page`.`groupID` = `group_member`.`groupID` + WHERE + `userID` = :userID AND + `status` = 1 + "); + + $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); + $stmt->execute(); + return $stmt; +} + +function selectAllUserPosts($db, $userID) { + $stmt = $db->prepare(" + SELECT + `postID`, + `author`, + `title`, + `content`, + `creationdate` + FROM + `post` + WHERE + `author` = :userID AND + `groupID` IS NULL + ORDER BY + `creationdate` DESC + "); + + $stmt->bindParam(':userID', $userID, PDO::PARAM_INT); + $stmt->execute(); + return $stmt; +} \ No newline at end of file