history.php: Simplify addition

This commit is contained in:
ruan 2018-05-31 09:01:20 +02:00
parent 05d10a211c
commit 4b3565b9aa
No known key found for this signature in database
GPG Key ID: 0D2EC1C52E469C0B

View File

@ -113,15 +113,15 @@ try {
$total = 0;
$count_st = $page->conn->prepare("SELECT
(SELECT COUNT(*) FROM $t_bans WHERE $field=:uuid0) as c_bans,
(SELECT COUNT(*) FROM $t_mutes WHERE $field=:uuid1) as c_mutes,
(SELECT COUNT(*) FROM $t_warnings WHERE $field=:uuid2) as c_warnings,
(SELECT COUNT(*) FROM $t_kicks WHERE $field=:uuid3) as c_kicks
(SELECT COUNT(*) FROM $t_bans WHERE $field=:uuid0) +
(SELECT COUNT(*) FROM $t_mutes WHERE $field=:uuid1) +
(SELECT COUNT(*) FROM $t_warnings WHERE $field=:uuid2) +
(SELECT COUNT(*) FROM $t_kicks WHERE $field=:uuid3) as total
");
for ($i = 0; $i <= 3; $i++) $count_st->bindParam(":uuid$i", $uuid, PDO::PARAM_STR);
if ($count_st->execute() && ($row = $count_st->fetch()) !== null) {
$total = $row['c_bans'] + $row['c_mutes'] + $row['c_warnings'] + $row['c_kicks'];
$total = $row['total'];
}
$count_st->closeCursor();