I’m starting with yii.
I have the following DB structure:
Table: Rows:
user [id,login,password,name,email]
userToProject [user_id,project_id,role]
project [id,name,status]
And I want to retrieve all the users working in a project with status=3 as role=manager. And this is my code by the way, I need to make the second join to reach the project status.
$criteria=new CDbCriteria;
$criteria->join='INNER JOIN {{userToProject}} a ON t.id=a.user_id and a.role='.Role::MANAGER;
$criteria->distinct=true;
return User::model()->findAll($criteria);
Can I make it with a criteria or should I implement an SQLcommand and run it?
Thanks