diff options
author | Ugnich Anton | 2013-12-19 02:04:18 +0700 |
---|---|---|
committer | Ugnich Anton | 2013-12-19 02:04:18 +0700 |
commit | 2bc4ccc437bb036de4ac5db23af8a276f1a708d5 (patch) | |
tree | 99baf7f7326b7edf7f15c8268943e9283dd3fc42 | |
parent | 5ec828b377b18d6cf56643796de8fdd44e8f1091 (diff) |
SubscriptionQueries.getJIDSubscribedToUserAndTags
-rw-r--r-- | src/com/juick/server/SubscriptionsQueries.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/juick/server/SubscriptionsQueries.java b/src/com/juick/server/SubscriptionsQueries.java index 9f9468cd7..ca382fc76 100644 --- a/src/com/juick/server/SubscriptionsQueries.java +++ b/src/com/juick/server/SubscriptionsQueries.java @@ -43,6 +43,28 @@ public class SubscriptionsQueries { return jids; } + public static ArrayList<String> getJIDSubscribedToUserAndTags(Connection sql, int uid, int mid) { + ArrayList<String> jids = new ArrayList<String>(); + + PreparedStatement stmt = null; + ResultSet rs = null; + try { + stmt = sql.prepareStatement("SELECT DISTINCT jid FROM jids WHERE active=1 AND user_id IN (SELECT suser_id FROM subscr_users WHERE user_id=? UNION SELECT suser_id FROM subscr_tags INNER JOIN messages_tags ON (messages_tags.message_id=? AND subscr_tags.tag_id=messages_tags.tag_id))"); + stmt.setInt(1, uid); + stmt.setInt(2, mid); + rs = stmt.executeQuery(); + rs.beforeFirst(); + while (rs.next()) { + jids.add(rs.getString(1)); + } + } catch (SQLException e) { + System.err.println(e); + } finally { + Utils.finishSQL(rs, stmt); + } + return jids; + } + public static ArrayList<String> getJIDSubscribedToComments(Connection sql, int mid, int ignore_uid) { ArrayList<String> jids = new ArrayList<String>(); |