I have 3 tables, the standard attitude is MANY TO MANY Users (id, ...) → Users_Has_Courses (Users_id, Courses_id) → Courses (id, ...)
Courses Model has the following relationship
'users' => array(self::MANY_MANY, 'Users', 'users_has_courses(Courses_id, Users_id)')
The user model has the following relationship
'courses' => array(self::MANY_MANY, 'Courses', 'users_has_courses(Users_id, Courses_id)')
Tell me, how can I get a list of courses at which the user with the specified "id" has not been subscribed to CActiveDataProvider? Other words, I need an analog of this simple SQL query
select * from Courses where id not in (select Courses_id from users_has_courses where Users_id = 2)
thanks for the help
source
share