From b103dff5f9f4de394ec047ae251696b66556336b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 3 Mar 2012 21:40:43 +0100 Subject: [PATCH] Adding For Update to query --- file/lib/data/chat/room/ChatRoomAction.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/file/lib/data/chat/room/ChatRoomAction.class.php b/file/lib/data/chat/room/ChatRoomAction.class.php index c5afc37..7f70a58 100644 --- a/file/lib/data/chat/room/ChatRoomAction.class.php +++ b/file/lib/data/chat/room/ChatRoomAction.class.php @@ -34,15 +34,16 @@ public function create() { $room = parent::create(); WCF::getDB()->beginTransaction(); - $sql = "SELECT max(position) as max - FROM wcf".WCF_N."_chat_room"; + $sql = "SELECT max(position) as max + FROM wcf".WCF_N."_chat_room + FOR UPDATE"; $stmt = WCF::getDB()->prepareStatement($sql); $stmt->execute(); $row = $stmt->fetchArray(); - $sql = "UPDATE wcf".WCF_N."_chat_room - SET position = ".($row['max'] + 1)." - WHERE roomID = ?"; + $sql = "UPDATE wcf".WCF_N."_chat_room + SET position = ".($row['max'] + 1)." + WHERE roomID = ?"; $stmt = WCF::getDB()->prepareStatement($sql); $stmt->execute(array($room->roomID)); WCF::getDB()->commitTransaction();