Re: Prevent double data in recursive find/findAll
> Thanks a lot, mate! I'll try it out. no worries mate when I start thinking about optimisations like this, I tend to pr/debug the full dataset that's being returned, and then add an unbindAll method for each model I need to tweak, though I wouldn't worry about optimising things until the app is nearing completion. jb -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Prevent double data in recursive find/findAll
Thanks a lot, mate! I'll try it out. On Mar 9, 7:54 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote: > > > My question is, is there a way to prevent that the same data is > > > fetched (and added to the results array) several times, without > > > lowering the recursion level? > > > check outhttp://bakery.cakephp.org/articles/view/183(or one of the > > other variants). > > > What I would do is: > > > // set recursive level > > $this->Group->recursive = 1; > > // unbind all associations except the Student model > > $this->Group->unbindAll(array('hasMany'=>array('Student'))); > > // unbind all assocations from the Student model to avoid > > $this->Group->Student->unbindAll(); > > // grab records > > $groups = $this->Group->findAll(); > > I meant recursive = 2 sorry! > > hth > > jon > > -- > > jon bennett > t: +44 (0) 1225 341 039 w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Prevent double data in recursive find/findAll
> > My question is, is there a way to prevent that the same data is > > fetched (and added to the results array) several times, without > > lowering the recursion level? > > check out http://bakery.cakephp.org/articles/view/183 (or one of the > other variants). > > What I would do is: > > // set recursive level > $this->Group->recursive = 1; > // unbind all associations except the Student model > $this->Group->unbindAll(array('hasMany'=>array('Student'))); > // unbind all assocations from the Student model to avoid > $this->Group->Student->unbindAll(); > // grab records > $groups = $this->Group->findAll(); I meant recursive = 2 sorry! hth jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Prevent double data in recursive find/findAll
> My question is, is there a way to prevent that the same data is > fetched (and added to the results array) several times, without > lowering the recursion level? check out http://bakery.cakephp.org/articles/view/183 (or one of the other variants). What I would do is: // set recursive level $this->Group->recursive = 1; // unbind all associations except the Student model $this->Group->unbindAll(array('hasMany'=>array('Student'))); // unbind all assocations from the Student model to avoid $this->Group->Student->unbindAll(); // grab records $groups = $this->Group->findAll(); hth jon -- jon bennett t: +44 (0) 1225 341 039 w: http://www.jben.net/ iChat (AIM): jbendotnet Skype: jon-bennett --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Prevent double data in recursive find/findAll
Hi, I'm creating an application where i use a lot of belongsTo and hasMany relations. It's kind of like a school. A school has many classes and the classes belongs to the school. Every class has many students who belong to the school. Now when I in my application do a findAll on, let's say, a group with a high recursion level, i.e. 5, the main structure resulting array looks something like this: (I'm skipping the details that doesn't matter) Group => array( Student => array( Group => array( Student => array( ... ) ... ) ... ) ... ) The same group and the same students are fetched several times (using different queries). Of course, with even more models (schools, regions, ...), the amount of data fetched grows huge! This might not have a very big impact on performance, but it sure doesn't feel good. :) My question is, is there a way to prevent that the same data is fetched (and added to the results array) several times, without lowering the recursion level? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---