finally i got something that’s challenging and twisting enough for you to conquer:
say i have these 3 tables:
tbl_user,
tbl_follow, (records the follow relationship between users. if user A follows user B, a new record will be inserted:
id:
following_id: the id of the following user
followed_id: the id of the followed user
)
tbl_move, (records the moves of every user, it has this attributes:
id:
move_id: the id of the user who made this move.
move_content:
)
The relationship between these 3 tables are clear: A user can have many followers and can be followed by many users. A user can have many moves.
Now the question is: How can I get a user’s followed users’ moves (AR) using CActiveDataProvider so that i can listed them somewhere?
I tried many times and find the relation too twisting to use our powerful CActiveDataProvider. But, perhaps some powerful mind can do?
$moveDataProvider = new CActiveDataProvider('move',array( //move, the table name
'criteria'=>array(
'condition'=>'move_id=:move_id',
//'with'=>array(''),
//'params'=>array(':move_uid'=>''),
),
));