blob: 9f9468cd7bfe2295e89972278824c0b23b8ae270 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.juick.server;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
/**
*
* @author ugnich
*/
public class SubscriptionsQueries {
public static ArrayList<String> getJIDSubscribedToUser(Connection sql, int uid, boolean friendsonly) {
ArrayList<String> jids = new ArrayList<String>();
PreparedStatement stmt = null;
ResultSet rs = null;
try {
if (friendsonly == false) {
stmt = sql.prepareStatement("SELECT jids.jid FROM subscr_users INNER JOIN jids ON (subscr_users.user_id=? AND subscr_users.suser_id=jids.user_id) WHERE jids.active=1");
stmt.setInt(1, uid);
} else {
stmt = sql.prepareStatement("SELECT jids.jid FROM subscr_users INNER JOIN jids ON (subscr_users.user_id=? AND subscr_users.suser_id=jids.user_id) WHERE jids.active=1 AND jids.user_id IN (SELECT wl_user_id FROM wl_users WHERE user_id=?)");
stmt.setInt(1, uid);
stmt.setInt(2, uid);
}
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>();
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = sql.prepareStatement("SELECT jids.jid FROM subscr_messages INNER JOIN jids ON (subscr_messages.message_id=? AND subscr_messages.suser_id=jids.user_id) WHERE jids.user_id!=? AND jids.active=1");
stmt.setInt(1, mid);
stmt.setInt(2, ignore_uid);
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;
}
}
|