diff options
author | Ugnich Anton | 2014-02-02 23:21:07 +0700 |
---|---|---|
committer | Ugnich Anton | 2014-02-02 23:21:07 +0700 |
commit | 636b44d06dfbf84210c44f488659e629ed4db0ec (patch) | |
tree | f2be72fa8e5370d78b64cfba0b063d3df7a6e45b /src | |
parent | 6a75cc16b2864aa4fb06e61eb9011d83497f607f (diff) |
MessagesQueries.getTags
Diffstat (limited to 'src')
-rw-r--r-- | src/com/juick/server/MessagesQueries.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java index 64ee3b96..bf26b70b 100644 --- a/src/com/juick/server/MessagesQueries.java +++ b/src/com/juick/server/MessagesQueries.java @@ -352,6 +352,35 @@ public class MessagesQueries { return mids; } + public static ArrayList<Integer> getTags(Connection sql, String tids, int visitor_uid, int before, int cnt) { + ArrayList<Integer> mids = new ArrayList<Integer>(20); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + if (before > 0) { + stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages_tags.tag_id IN (" + tids + ") AND messages.message_id<? AND (messages.privacy>0 OR messages.user_id=?) ORDER BY messages.message_id DESC LIMIT ?"); + stmt.setInt(1, before); + stmt.setInt(2, visitor_uid); + stmt.setInt(3, cnt); + } else { + stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages_tags.tag_id IN (" + tids + ") AND (messages.privacy>0 OR messages.user_id=?) ORDER BY messages.message_id DESC LIMIT ?"); + stmt.setInt(1, visitor_uid); + stmt.setInt(2, cnt); + } + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + mids.add(rs.getInt(1)); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return mids; + } + public static ArrayList<Integer> getPlace(Connection sql, int place_id, int visitor_uid, int before) { ArrayList<Integer> mids = new ArrayList<Integer>(20); |