From f8193d10500da5155f9dcd8a18758d3edd70193e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 19 May 2012 20:41:33 +0200 Subject: [PATCH] Optimizing ChatRoom::getUsers() --- file/lib/data/chat/room/ChatRoom.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/file/lib/data/chat/room/ChatRoom.class.php b/file/lib/data/chat/room/ChatRoom.class.php index 1d2d831..aed4fa5 100644 --- a/file/lib/data/chat/room/ChatRoom.class.php +++ b/file/lib/data/chat/room/ChatRoom.class.php @@ -135,7 +135,7 @@ public function getUsers() { $userIDs = array(); while ($userIDs[] = $stmt->fetchColumn()); - if (!count($userIDs)) return array(); + if (empty($userIDs)) return array(); $sql = "SELECT u.*, @@ -146,16 +146,15 @@ public function getUsers() { wcf".WCF_N."_user_storage s ON ( u.userID = s.userID - AND s.field = ? - AND s.packageID = ? + AND s.field = ? + AND s.packageID = ? ) WHERE - u.userID IN (".rtrim(str_repeat('?,', count($userIDs)), ',').") + u.userID IN (?) ORDER BY u.username ASC"; $stmt = WCF::getDB()->prepareStatement($sql); - array_unshift($userIDs, 'away', $packageID); - $stmt->execute($userIDs); + $stmt->execute(array('away', $packageID, $userIDs)); return $stmt->fetchObjects('\wcf\data\user\User'); }