Can CDbCriterai and CActiveDataProvider join 3 tables?

Here is what I want to do in SQL:


select	

	r.recipe_name,	

	i.ingredients_list,	

	p.products_list 

from	

	recipes r,   

    ingredients i,   

    products p 

where 	

   r.RecipeID = i.IngreRecipeID and	

   i.IngreProductID = p.ProductID ;



How can I give WHERE clause to CActiveDataProvider or CDbCriteria, if they are possible to handle joining 3 tables?

Thank you!

Hello there,

First of all I think you have not read the blog tutorial or probably the definite guide. I recomend doing so and this question as well as others will be answered there.

For this paricular I can see that recipes are connected to indegrients are connected to products?!

This mean yyou should have a model for each of this, feed the active data provider with the recipes you want and use the relations to display extra info. If you don’t like lazy loading consider cdbcriteria with property/method.

Thanks, this help me clear out some confusion. That’s why the blog demo only feed CActiveDataProvider with only ‘Post’ AR, it is the place I am lost, because I am asking myself, what happens to the other two AR class?

BTW, I do read Guide and Reference several times in the past few month, but due to my limitations, some part I just couldn’t understand.