From bf87d20985664e4a0798a4abccc31ef01c783ea0 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Thu, 26 Jan 2017 15:14:51 +0100 Subject: [PATCH] Queries for niet slecht --- website/public/API/nietSlecht.php | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 website/public/API/nietSlecht.php diff --git a/website/public/API/nietSlecht.php b/website/public/API/nietSlecht.php new file mode 100644 index 0000000..e37c8e0 --- /dev/null +++ b/website/public/API/nietSlecht.php @@ -0,0 +1,41 @@ +prepare(" + SELECT + `userID` + FROM + `niet_slecht` + WHERE + `postID` = :postID + "); + $stmt->bindParam(":postID", $postID); + $stmt->execute(); + return $stmt->rowCount(); +} + +function getNietSlechtUsersForPost(int $postID) { + $stmt = $GLOBALS["db"]->prepare(" + SELECT + `fname`, + `lname`, + CONCAT(`user`.`fname`, ' ', `user`.`lname`) as `fullname` + FROM + `user` + INNER JOIN + `niet_slecht` + WHERE + `user`.`userID` = `niet_slecht`.`userID` AND + `niet_slecht`.`postID` = :postID + "); + $stmt->bindParam(":postID", $postID); + $stmt->execute(); + $rows = $stmt->fetchAll(); + foreach ($rows as $row) { + print($row["fullname"]); + } +} \ No newline at end of file