Open Wyliemaster opened 1 year ago
I've come up with a solution however a few things to note:
if($type == "relative"){
$user = $result[0];
$extid = $user["extID"];
// TL;DR fetches all users who aren't banned and have more stars than the account and then returns the count as rank
$query = $db->prepare("SELECT `rank`
FROM (
SELECT
next_user.stars,
next_user.extID,
COUNT(*) AS `rank`
FROM
users AS next_user
JOIN
users AS prev_user
ON next_user.stars < prev_user.stars
OR (next_user.stars = prev_user.stars AND next_user.extID = prev_user.extID)
WHERE
next_user.isBanned = '0'
AND next_user.gameVersion $sign
GROUP BY
next_user.stars, next_user.extID
) AS ranked_users
WHERE
extID = ?"); // don't need :extid since it isn't used multiple times
$query->execute([$extid]);
$data = $query->fetch();
$xi = $data["rank"] - 1;
}
Error
Error logs say the issue is around here
Code Snippet
After some debugging it appears to be
@rownum
which is causing the issueServer version: 8.0.20-0ubuntu0.20.04.1 - (Ubuntu)