Criteria For Many To Many Relationship


I’m trying to do something really simple but I can’t find the answer anywhere and it must be something that people are doing all the time on most projects.

I have three tables: users, projects and users_projects. users_projects has two columns, user_id and project_id, pretty common right?

What I can’t find is how to make an ActiveDataProvider to get all the projects for a given user_id.

Can someone tell me what criteria I need to include please?

Thanks in advance.

Have you read the guide about relational active records?

Hi, yes I did read that thankyou and I’ve worked out that I needed an inner join:





'joinType'=>'INNER JOIN',