Thta's great that the Containable behaviour works and all. However I shouldn't need to use it, this should work as far as I can see. My question is why isn't it working, the recursive = 2 option is there so that something like this works.
On Feb 13, 7:51 pm, brian <[email protected]> wrote: > Again, use Containable. Where you get the idea that using the > 'contain' option "adds more things to do" I'm not sure. It's certainly > made my code a heck of a lot tidier and simpler to understand. > > I bow in the general direction of whomever wrote that (Mariano?) > > On Fri, Feb 13, 2009 at 6:36 PM, Arak Tai'Roth <[email protected]> > wrote: > > > Anyone else have an idea? > > > On Feb 13, 10:34 am, "Arak Tai'Roth" <[email protected]> wrote: > >> I don't think that would help, and adds more things to do when as far > >> as I know, this should work fine. I will detail my problem a little > >> more here: > > >> I have three models, Build, Status, and Phase (or Builds, Statuses, > >> and Phases), they are linked in this manner: > >> class Build extends AppModel > >> { > >> var $name = 'Build'; > >> var $belongsTo = 'Status'; > > >> } > > >> class Status extends AppModel > >> { > >> var $name = 'Status'; > >> var $belongsTo = 'Phase'; > > >> } > > >> This line of code: > >> $dbbuilds = $this->Build->find('first', array('fields' => array('id', > >> 'name', 'slug', 'description'), 'conditions' => array('slug' => > >> $slug), 'recursive' => 2)); > > >> should grab the data in the Build model as indicated by the fields > >> array, but it should also grab the data in the Status model and in the > >> Phase model. It does grab the data in the Status model, yet does not > >> grab the data in the Phase model. I thought that was wierd and started > >> looking around for a why. I stumbled across the link I posted above > >> and decided to take out the fields array, so I ended up with this: > > >> $dbbuilds = $this->Build->find('first', array('conditions' => array > >> ('slug' => $slug), 'recursive' => 2)); > > >> And for some reason, this grabs all of the data in the Build model, > >> Status model, and the Phase model as it should. However I just don't > >> need all the data given to me in the Build model so this isn't a great > >> solution. And I would like to know why it is breaking in the first > >> line of code with the fields array being used, and what I can do to > >> fix it. > > >> On Feb 13, 1:52 am, "Liebermann, Anja Carolin" > > >> <[email protected]> wrote: > >> > Hi Arak, > > >> > I am not sure if I understand your problem correctly, but maybe the > >> > containable behaviour can > >> > help?http://book.cakephp.org/view/474/Containable > > >> > Anja > > >> > -----Ursprüngliche Nachricht----- > >> > Von: [email protected] [mailto:[email protected]] Im > >> > Auftrag von Arak Tai'Roth > >> > Gesendet: Donnerstag, 12. Februar 2009 21:55 > >> > An: CakePHP > >> > Betreff: recursive 2 with fields problem > > >> > So I have been looking around trying to figure out what my problem is > >> > and stumbled across this. > > >> >http://groups.google.com/group/cake-php/browse_thread/thread/3ded2f1b... > > >> > It's my exact issue, however there is no answer, so I was wondering if > >> > someone has an answer for this. > > >> > The issue if you didn't go to the link is this. Using the recursive=2 > >> > option in $this->Model->find() yields the results I need, however I want > >> > to limit what fields are found in the first model, so I use the 'fields' > >> > = array() option as well, and as soon as I do, I no longer get the > >> > second model that is indirectly related. > > >> > Any idea what I'm doing wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
