Merge branch 'master' into kevin-prototype

This commit is contained in:
K. Nobel
2017-01-20 13:08:07 +01:00
4 changed files with 73 additions and 16 deletions

View File

@@ -170,4 +170,30 @@ function changeUserStatusByID($id, $status) {
}
?>
function selectRandomNotFriendUser($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`user`.`username`
FROM
`user`
WHERE
`userID` NOT IN (SELECT
`user1ID`
FROM
`friendship`
WHERE `user1ID` = :userID) OR
`userID` NOT IN (SELECT
`user2ID`
FROM
`friendship`
WHERE `user2ID` = :userID)
ORDER BY
RAND()
LIMIT
1
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetch();
}