Merge branch 'master' into 'kevin-prototype'
# Conflicts: # website/queries/friendship.php # website/queries/user.php
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user