If we have db something like this:
User -> Projects -> Tasks
Now if we follow the YII Active Record relations, we'll have following relations:
User -> 'hasMany' => Projects
Project -> 'belongsTo' => User
Project -> 'hasMany' => Tasks
Task -> 'belongsTo' => Project
So this is a common Project and task relationship.
Currently, I am doing:
$Criteria = new CDbCriteria; $Criteria->with = array( 'projects'=>array( 'with'=>array( 'tasks' ) ) ); $User::model()->find($Criteria);
foreach( User->Project as project ){ foreach( project->Tasks as task){ **** list tasks **** } }
But want to list all the tasks of all the projects, order by TASK DATE, without looping on Project. How can I do that ? I have tried the following but it did not work:
foreach( User->Project->Task as task ){ *** list tasks *** }
Thanks