Pardon my use of a Rails example here, but that is my reference point. Let's say I have two models, Album and Image. Obviously:
Album hasMany Images Image belongsTo Album In Rails, I would do this: albums = Album.find(:all, :include => [ :images ]) Which would produce this query: SELECT albums.`id` AS t0_r0, albums.`name` AS t0_r1, images.`id` AS t1_r0, images.`album_id` AS t1_r1, images.`name` AS t1_r2 FROM albums LEFT OUTER JOIN images ON images.album_id = albums.id I'm trying to figure out how to accomplish the same thing in Cake. First, I tried this: $albums = $this->Album->findAll(); This creates one query to find the albums, then 1 query for each of those albums to fetch the image data. So, if their are 5 albums, 6 queries. This does the exact same thing: $albums = $this->Album->Image->findAll(); So, what is the Cake way of fetching associations with one big query? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
