From 951ac49ab54f2b1cac4e52627f6b906c0a86f6c6 Mon Sep 17 00:00:00 2001 From: uckelman Date: Tue, 27 Apr 2010 22:38:16 +0000 Subject: Always get last-edited message id for any post id. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6774 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/Bridge.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Bridge.php b/src/Bridge.php index b428fff..91247b8 100644 --- a/src/Bridge.php +++ b/src/Bridge.php @@ -26,8 +26,11 @@ class Bridge { public function getMessageId($postId) { throw_if_null($postId); - $sql = 'SELECT message_id FROM posts ' . - 'WHERE post_id = ' . $postId; + $sql = 'SELECT p1.message_id FROM posts AS p1 ' . + 'LEFT OUTER JOIN posts AS p2 ON (' . + 'p1.post_id = p2.post_id AND ' . + 'p1.edit_id < p2.edit_id' . + ') WHERE p2.post_id IS NULL'; $row = $this->get_exactly_one_row($sql); return $row ? $row['message_id'] : false; @@ -100,6 +103,8 @@ class Bridge { public function unregisterPost($postId) { throw_if_null($postId); +# FIXME: this might need adjusting now that there can be more than one +# message id per post id. $sql = 'DELETE FROM posts WHERE post_id = ' . $postId; $count = $this->db->exec($sql); -- cgit v1.2.3