From: Marcel Werk Date: Thu, 16 May 2013 19:40:22 +0000 (+0200) Subject: Small optimization X-Git-Tag: 2.0.0_Beta_1~173 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e563f9ff39cabc7155ee5215e4663244fcc9d4fd;p=GitHub%2FWoltLab%2FWCF.git Small optimization Fixes #1216 --- 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)); } /**