Batch verification into header query when possible

This commit is contained in:
ruan 2020-08-23 14:21:34 +02:00
parent 2b511094d2
commit 9f54f33a91
2 changed files with 14 additions and 7 deletions

View File

@ -13,11 +13,17 @@ function __construct($page) {
$t_warnings = $t['warnings'];
$t_kicks = $t['kicks'];
try {
$st = $page->conn->query("SELECT
(SELECT COUNT(*) FROM $t_bans),
(SELECT COUNT(*) FROM $t_mutes),
(SELECT COUNT(*) FROM $t_warnings),
(SELECT COUNT(*) FROM $t_kicks)");
$sql = "SELECT
(SELECT id FROM $t_bans ORDER BY id DESC LIMIT 1),
(SELECT id FROM $t_mutes ORDER BY id DESC LIMIT 1),
(SELECT id FROM $t_warnings ORDER BY id DESC LIMIT 1),
(SELECT id FROM $t_kicks ORDER BY id DESC LIMIT 1)";
if ($page->settings->verify) {
$sql .= ",(SELECT id FROM " . $t['config'] . " LIMIT 1)";
}
$st = $page->conn->query($sql);
($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.');
$st->closeCursor();
$this->count = array(

View File

@ -1,5 +1,4 @@
<?php
if (class_exists("Settings")) return;
class Settings {
public static $TRUE = "1", $FALSE = "0";
@ -163,6 +162,7 @@ class Settings {
if (!$this->show_silent_bans) {
$this->active_query = self::append_query($this->active_query, "silent=" . Settings::$FALSE);
}
$this->verify = false;
$this->test_strftime();
@ -176,6 +176,7 @@ class Settings {
}
protected function connect($verify = true) {
$this->verify = $verify;
$driver = $this->driver;
$host = $this->host;
$port = $this->port;
@ -201,7 +202,7 @@ class Settings {
try {
$this->conn = new PDO($dsn, $username, $password, $options);
if ($verify) {
if (!$this->header_show_totals && $verify) {
$st = $this->conn->query("SELECT * FROM " . $this->table['config'] . " LIMIT 1;");
$st->fetch();
$st->closeCursor();