Hi All,
I'm building my first site with cake, and am working my way through
the documentation, but so far this part is confusing.
I've got a page that shows a user's profile, the avatars of the user's
"friends," blog posts by the user, the number of comments for each
blog post, and comments by other users about that user, along with the
avatars of the commenters.
I've worked out the relationships between the models, but what I don't
know is how to access the specific data I want without doing 2 or 3
levels of recursion on a find() for the user. This is what I'm doing
right now, and it works but it's incredibly bloated. I'm getting back
all sorts of data I don't need and page load times are rather long.
I'd like to figure out the syntax for doing a find on just the avatars
for the user's friends. Right now, I do it like this:
In the controller:
$this->set('data', $this->User->find(null, null, null, 3));
In the view:
foreach ($data['Friends'] as $friend):
echo $friend['Profile']['avatar'];
endforeach;
I'd like to figure out how to do something like:
$this->set('friends', $this->User->Friends->Profiles->findAll());
This returns every profile in the system, not just those for the
user's friends. I'm sure I'm just missing something in the syntax and
there's a straightforward way to do this. I could just write a query,
but I'd like to figure out how to do it through the framework.
Thanks for your help!
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---