I’m trying to do some relational querys with ActiveRecord.
I have a Tutorial model that BELONGS TO a Classroom model (Classroom has many Tutorials). And a Classroom has many Students, but Student has many Classrooms, so I did a relational table for that MANY TO MANY relation.
ActiveRecord is doing it for You. If you want display students You should put there relation to classroom and from classroom to tutorials.
And if You do that you can easy show $model->classroom->tutorials->some_value, classroom is array and tutorials is array (couse of has_many relation) so You will need two loops to display it.
And $criteria->with is only if You want to do it in one query, otherwise You dont need it.
Thanks for your answer. But, is it possible the other way round? I mean, using CDBCriteria for Tutorial model, because I’m trying to show Classrooms Tutorials where the student is registered on, but at the same time, Tutorials of classrooms from a specific Teacher (Classroom has one teacher). That’s because I want to use the CListView widget.