Fix: add/delete player count bug

This commit is contained in:
2018-08-06 18:23:34 +09:00
parent f39b64d60e
commit 871d402dba
3 changed files with 87 additions and 22 deletions
+36 -1
View File
@@ -43,8 +43,11 @@ if($result === null) {
exit;
}
increase_player_count($maestroID, 1);
// increase_player_count($maestroID, 1);
$count = count_registered_player($maestroID);
update_count_registered_player($maestroID, $count);
set_data("count", $count);
send_result_success();
exit;
@@ -131,4 +134,36 @@ function increase_player_count($maestroID, $count) {
$stmt->execute();
}
function count_registered_player($maestroID) {
global $db_conn;
$query = "
SELECT COUNT(PlayerID)
FROM moty_player
WHERE MaestroID = ? AND AccountType = 0
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroID);
$stmt->execute();
$stmt->bind_result($countPlayer);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
return $countPlayer;
}
function update_count_registered_player($maestroID, $countPlayer) {
global $db_conn;
$query = "
UPDATE moty_maestro
SET PlayerCount = ?
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ii", $countPlayer, $maestroID);
$stmt->execute();
}
?>