There are 3 tables, a standard many-to-many.
Users(id,...) -> Users_Has_Courses(Users_id, Courses_id) -> Courses(id,...)
Relationship in the model Courses
'users' => array(self::many_many relations, 'Users', 'users_has_courses(Courses_id, Users_id)')
in the model Users
'courses' => array(self::many_many relations, 'Courses', 'users_has_courses(Users_id, Courses_id)'),
Tell me how to get the list of courses that are not signed by the user with the specified id, i.e. the analogue of the usual request
select * from Courses where id not in (select Courses_id from users_has_courses where Users_id = 2)