How To Setup Self Relation

Hello Guys,

I am using Yii 1.x version.

I am stuck while setting up a relation with same table using two different model. my scenario is something like this.

  1. There are two tables, user and user_friend_list

  2. Two different model for each table User & UserFriendList.

Following are the fields for my table.

User: id, firstname, lastname.

UserFriendList: id, user_id,friend_user_id

I want to set up relation between two model so that i can fetch all friend information of any user. Kindly suggest me what would be best approach to achieve this???


User Table store user information.

User Friend List table store friend list of user.


Please check the link below

A user can have one or more friends

 'posts'=>array(self::HAS_MANY, 'Post', 'author_id'),

Hi, Thanks for response.

I have found solution on following page. http : // / 1lCmDWz