Merge branch 'master' into 'kevin-prototype'

# Conflicts:
#   website/queries/friendship.php
#   website/queries/user.php
This commit is contained in:
Kevin Nobel
2017-01-18 16:22:29 +01:00
35 changed files with 1683 additions and 571 deletions

View File

@@ -84,4 +84,89 @@ function selectAllUserPosts($db, $userID) {
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt;
}
}
function select20UsersFromN($db, $n) {
return $db->query("
SELECT
`userID`,
`username`,
`role`,
`bancomment`
FROM
`user`
ORDER BY
`role`,
`username`
LIMIT
$n, 20
");
}
function search20UsersFromN($db, $n, $keyword) {
$q = $db->prepare("
SELECT
`userID`,
`username`,
`role`,
`bancomment`
FROM
`user`
WHERE
`username` LIKE :keyword
ORDER BY
`username`
LIMIT
:n, 20
");
$keyword = "%$keyword%";
$q->bindParam(':keyword', $keyword);
$q->bindParam(':n', $n, PDO::PARAM_INT);
$q->execute();
return $q;
}
function search20UsersFromNByStatus($db, $n, $keyword, $status) {
$q = $db->prepare("
SELECT
`userID`,
`username`,
`role`,
`bancomment`
FROM
`user`
WHERE
`username` LIKE :keyword AND
FIND_IN_SET (`role`, :statuses)
ORDER BY
`role`,
`username`
LIMIT
:n, 20
");
$keyword = "%$keyword%";
$q->bindParam(':keyword', $keyword);
$q->bindParam(':n', $n, PDO::PARAM_INT);
$statuses = implode(',', $status);
$q->bindParam(':statuses', $statuses);
$q->execute();
return $q;
}
function changeUserStatusByID($db, $id, $status) {
$q = $db->query("
UPDATE
`user`
SET
`role` = $status
WHERE
`userID` = $id
");
return $q;
}
?>