mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 16:32:45 +00:00
Reduce wasted queries
This commit is contained in:
parent
89267777d2
commit
23e3d57c5c
@ -5,6 +5,7 @@ require_once './includes/settings.php';
|
||||
|
||||
litebans_connect();
|
||||
|
||||
|
||||
function get_query($table) {
|
||||
global $table_history, $active_query, $limit_per_page;
|
||||
return 'SELECT * FROM ' . $table . ' INNER JOIN ' . $table_history . ' on ' . $table . '.uuid=' . $table_history . '.uuid ' . $active_query .
|
||||
@ -25,12 +26,16 @@ function get_avatar($name) {
|
||||
return "<img src='https://cravatar.eu/avatar/" . $name . "/25' style='margin-bottom:5px;margin-right:5px;border-radius:2px;' />" . $name;
|
||||
}
|
||||
|
||||
$banner_name_cache = [];
|
||||
|
||||
function get_banner_name($row) {
|
||||
global $conn, $table_history;
|
||||
global $conn, $table_history, $banner_name_cache;
|
||||
$uuid = $row['banned_by_uuid'];
|
||||
if (array_key_exists($uuid, $banner_name_cache)) return $banner_name_cache[$uuid];
|
||||
$stmt = $conn->prepare("SELECT name FROM " . $table_history . " WHERE uuid=? ORDER BY date DESC LIMIT 1");
|
||||
if ($stmt->execute(array($uuid)) && $r = $stmt->fetch()) {
|
||||
$banner = $r['name'];
|
||||
$banner_name_cache[$uuid] = $banner;
|
||||
return $banner;
|
||||
}
|
||||
//return "null";
|
||||
|
Loading…
x
Reference in New Issue
Block a user