Hello,
I'm trying to get all the users who are in a certain cohort and enrolled in a certain course. But i don't know why when i use get_records_sql() the function returns the correct users but they doesn't have the correct id. The id's should be 2, 3, and 4 but i always get 4 for each user.
Here's my sql statement:
SELECT * FROM {user} user JOIN {cohort_members} cohort
ON user.id = cohort.userid JOIN {user_enrolments} userenrol ON user.id =
userenrol.userid JOIN {enrol} enrol ON userenrol.enrolid = enrol.id WHERE 1 = 1
AND cohort.cohortid = 1 AND enrol.courseid = 3
// Here the cohort is 1 and the course is 3
// Don't take note of the '1 = 1'
This should return 3 users whith the ids 2, 3 and 4 but it only returns 1 user with the id 4 (that's because get_records_sql() regroups them because he finds the same id for all)
Of course when i try this statement in phpmyadmin it works perfectly...
Please help me i don't know what to do anymore...