Re: Set different recursive values for different models

2009-07-15 Thread Jamie

The best thing, in my opinion, is to do the following:

- set recursive to -1 in AppModel
- enable Containable behavior, also in AppModel

With containable behavior, you determine exactly what data is returned
by your queries. So, if you want to find all Profiles, you would do
this (from ProfilesController):

$this->Profile->find('all');

That'll return just an array of profiles with no related data. If you
want to find the friends associated with the profiles:

$this->Profile->find('all', array(
'contain' => array('Friend')
));

That'll return an array of profiles and friends. And if you want to
take it one step further and find a model associated with Friend -
let's say Friend hasMany Games - then you can put in a nested array:

$this->Profile->find('all', array(
'contain' => array('Friend' => array('Game'))
));

Make sense?
Check out how containable behavior works at: 
http://book.cakephp.org/view/474/Containable

- Jamie

On Jul 15, 1:31 pm, David  wrote:
> Ok so I have a profile model that hasMany favorite games and friends.
> To find the friends icon extension to display their user icon I have
> to set the recursive property to 3 in my profile model.  This then
> causes the favorite games to fetch their game comments and ratings and
> such.  Is there any way I can make the favorite games model only
> follow a recursive setting of 2, but have the friend model follow a
> recursive setting of 3 to prevent the fetching of unnecessary data?  I
> could get around this by unbinding several models, but this seems like
> a lot of work, and it feels like it would defeat the benefits of using
> cakephp's help.  Any thoughts?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Set different recursive values for different models

2009-07-15 Thread David

Ok so I have a profile model that hasMany favorite games and friends.
To find the friends icon extension to display their user icon I have
to set the recursive property to 3 in my profile model.  This then
causes the favorite games to fetch their game comments and ratings and
such.  Is there any way I can make the favorite games model only
follow a recursive setting of 2, but have the friend model follow a
recursive setting of 3 to prevent the fetching of unnecessary data?  I
could get around this by unbinding several models, but this seems like
a lot of work, and it feels like it would defeat the benefits of using
cakephp's help.  Any thoughts?
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---