Thursday, August 27, 2009

Using belongsTo and hasMany relationships: Is it possible to access tables through a chain of relationships?

This is my setup:

A 'user' hasMany 'userpage's.
A 'user' belongsTo an 'animal'.

I would like to be able to display user information as well as some
information about the user's animal on a userpage view.

I perform a find query to get the userpage id, user_id, animal_id.

Is there a way to search for Animal information as well?
This won't work because of the last field, but this is conceptually
what I want:

'fields'=>array('user_id', 'id', 'User.animal_id',
'User.Animal.frontfilename')

Thanks in advance!
~Sarah
--~--~---------~--~----~------------~-------~--~----~
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: