From e563f9ff39cabc7155ee5215e4663244fcc9d4fd Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 16 May 2013 21:40:22 +0200 Subject: [PATCH] Small optimization Fixes #1216 --- .../files/lib/data/user/UserEditor.class.php | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/wcfsetup/install/files/lib/data/user/UserEditor.class.php b/wcfsetup/install/files/lib/data/user/UserEditor.class.php index 3da6a73d1b..8a395a125f 100644 --- a/wcfsetup/install/files/lib/data/user/UserEditor.class.php +++ b/wcfsetup/install/files/lib/data/user/UserEditor.class.php @@ -160,9 +160,9 @@ class UserEditor extends DatabaseObjectEditor implements IEditableCachedObject { // insert new groups if (!empty($groupIDs)) { - $sql = "INSERT INTO wcf".WCF_N."_user_to_group - (userID, groupID) - VALUES (?, ?)"; + $sql = "INSERT IGNORE INTO wcf".WCF_N."_user_to_group + (userID, groupID) + VALUES (?, ?)"; $statement = WCF::getDB()->prepareStatement($sql); foreach ($groupIDs as $groupID) { $statement->execute(array($this->userID, $groupID)); @@ -176,24 +176,11 @@ class UserEditor extends DatabaseObjectEditor implements IEditableCachedObject { * @param integer $groupID */ public function addToGroup($groupID) { - $sql = "SELECT COUNT(*) AS count - FROM wcf".WCF_N."_user_to_group - WHERE userID = ? - AND groupID = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - $this->userID, - $groupID - )); - $row = $statement->fetchArray(); - - if (!$row['count']) { - $sql = "INSERT INTO wcf".WCF_N."_user_to_group + $sql = "INSERT IGNORE INTO wcf".WCF_N."_user_to_group (userID, groupID) - VALUES (?, ?)"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->userID, $groupID)); - } + VALUES (?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($this->userID, $groupID)); } /** -- 2.20.1