Skip to content
Snippets Groups Projects
Commit c9da6796 authored by Charlie Darques's avatar Charlie Darques
Browse files

ajout méthode récupérer les abonnés d'un thread

parent 0ce0679d
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,29 @@ public class ThreadDAO {
return messages;
}
public List<User> getFollowersOfThread(int threadId) throws SQLException{
ArrayList<User> followers = new ArrayList<>();
try {
PreparedStatement ps = this.con.prepareStatement("""
SELECT u.userID, u.username, u.password FROM userAccount AS u
INNER JOIN follow AS f ON f.userID=u.userID
WHERE f.threadID_follow = ?
""");
ps.setInt(1, threadId);
ResultSet rs = ps.executeQuery();
while(rs.next()){
int userId = rs.getInt(1);
String username = rs.getString(2);
String password = rs.getString(3);
followers.add(new User(userId, username, password));
}
} catch (SQLException sqle) {
sqle.getStackTrace();
}
return followers;
}
// Créer un thread
public void createThread(User user, String threadName) throws SQLException {
PreparedStatement ps = this.con.prepareStatement("INSERT INTO thread (userID_thread, threadName) VALUES(?, ?)");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment