mirror of
				https://gitlab.com/ruany/litebans-php.git
				synced 2025-10-30 14:32:25 +00:00 
			
		
		
		
	Optimize queries
This commit is contained in:
		
							parent
							
								
									4b3565b9aa
								
							
						
					
					
						commit
						5857a0d374
					
				| @ -116,12 +116,12 @@ try { | ||||
|         (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 | ||||
|         (SELECT COUNT(*) FROM $t_kicks WHERE $field=:uuid3) | ||||
|     ");
 | ||||
|     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['total']; | ||||
|     if ($count_st->execute() && ($row = $count_st->fetch(PDO::FETCH_NUM)) !== null) { | ||||
|         $total = $row[0]; | ||||
|     } | ||||
|     $count_st->closeCursor(); | ||||
| 
 | ||||
|  | ||||
| @ -14,17 +14,17 @@ function __construct($page) { | ||||
|         $t_kicks = $t['kicks']; | ||||
|         try { | ||||
|             $st = $page->conn->query("SELECT
 | ||||
|             (SELECT COUNT(*) FROM $t_bans) AS c_bans, | ||||
|             (SELECT COUNT(*) FROM $t_mutes) AS c_mutes, | ||||
|             (SELECT COUNT(*) FROM $t_warnings) AS c_warnings, | ||||
|             (SELECT COUNT(*) FROM $t_kicks) AS c_kicks");
 | ||||
|             ($row = $st->fetch(PDO::FETCH_ASSOC)) or die('Failed to fetch row counts.'); | ||||
|             (SELECT COUNT(*) FROM $t_bans), | ||||
|             (SELECT COUNT(*) FROM $t_mutes), | ||||
|             (SELECT COUNT(*) FROM $t_warnings), | ||||
|             (SELECT COUNT(*) FROM $t_kicks)");
 | ||||
|             ($row = $st->fetch(PDO::FETCH_NUM)) or die('Failed to fetch row counts.'); | ||||
|             $st->closeCursor(); | ||||
|             $this->count = array( | ||||
|                 'bans.php'     => $row['c_bans'], | ||||
|                 'mutes.php'    => $row['c_mutes'], | ||||
|                 'warnings.php' => $row['c_warnings'], | ||||
|                 'kicks.php'    => $row['c_kicks'], | ||||
|                 'bans.php'     => $row[0], | ||||
|                 'mutes.php'    => $row[1], | ||||
|                 'warnings.php' => $row[2], | ||||
|                 'kicks.php'    => $row[3], | ||||
|             ); | ||||
|         } catch (PDOException $ex) { | ||||
|             Settings::handle_error($page->settings, $ex); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 ruan
						ruan