I have the following models:
User:
- hasOne Profile, Page
- hasMany Comment
Comment:
- belongsTo User, Page, Profile
Page:
- belongsTo User
- hasMany Comment
Profile:
- belongsTo User
When I retrieve a page, I want to get the associated Comments, and for each comment I want the Profile.
My comments table has fields page_id and user_id. My profile table has user_id.
So, I assume I need to do something like
Comment belongsTo
'Profile' => array(
'conditions' => array('Profile.user_id' => 'Comment.user_id')
)
but that's not working - it returns a blank profile record.
I am using CakePHP 2.0.