Saturday, November 1, 2008

Associations two levels deep

Hello I am having a Users friend model which belongs to User Model which hasOne Profile, so:

UsersFriend(user_id, friend_id):
var $belongsTo = array('User' => array('foreignKey'=>'friend_id',
                                         'fields'=>array('User.id', 'User.uid', 'User.first_name',
                                                'User.last_name', 'User.picture_path')));

User:
var $hasOne = array('Profile' => array(
                            'className' => 'Profile',
                            'dependent' => true));

when i call paginate on UsersFriend:

$data = $this->paginate('UsersFriend',
                        array('UsersFriend.user_id'=>$user['User']['id']));

I dont get the user's friend's profile though a User hasOne association with Profile. Any idea on how to do this?

Thanks.


--
Thanks & Regards,
Novice.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: