mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 16:32:45 +00:00
Batch verification into header query when possible
This commit is contained in:
parent
2b511094d2
commit
9f54f33a91
@ -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(
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user