I have 3 models (User, Post and favorite) with relations as mentioned below.
User has many Posts
User has many Favorites
Favorite belongs to User
[b]
[/b]
I need to list all favorite posts for a given user on his/her profile and query mentioned below does the job.
[sql]SELECT * FROM post WHERE id IN (SELECT post_id FROM favorite WHERE user_id=:user_id)[/sql]
However I want to avoid writing SQL and instead would prefer to use Yii AR functions to do the same. Could anyone please help me in substituting this SQL with appropriate Yii conventions.