Re: findAll with specific fields and hasMany relation
I would probably use bindModel with conditions: http://groups.google.ca/group/cake-php/browse_thread/thread/dcbb867063e4696c/4fbbbd0bf6223330?lnk=gst&q=bindmodel&rnum=9#4fbbbd0bf6223330 On May 9, 1:08 pm, robechar <[EMAIL PROTECTED]> wrote: > This is the only way I have found to do this, but perhaps some one > knows a better method? > > this->A->hasMany['B']['fields'] = 'id'; > $this->A->findAll(); > > On May 8, 3:46 am, peper <[EMAIL PROTECTED]> wrote: > > > Hi, > > > Let's say I've got two models A and B , and the relation is > > A hasMany B > > > Now I want to "findAll" A's with corresponding B's . > > > this->A->findAll() works OK. > > > I can specify fields from A > > > this->A->findAll(null,"A.ID"); > > > I've got only ID from A and a list of all B's > > > Now I want to specify fields from B. > > > this->A->findAll(null,"B.ID"); > > > It doesn't work. It's a SQL error, becasue Cake makes : > > "SELECT ...FROM 'a' as 'A' WHERE . " > > and there's no such collumn : "B.ID" > > > Is it possible to specify fields in hasMany relation ? --~--~-~--~~~---~--~~ 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: findAll with specific fields and hasMany relation
This is the only way I have found to do this, but perhaps some one knows a better method? this->A->hasMany['B']['fields'] = 'id'; $this->A->findAll(); On May 8, 3:46 am, peper <[EMAIL PROTECTED]> wrote: > Hi, > > Let's say I've got two models A and B , and the relation is > A hasMany B > > Now I want to "findAll" A's with corresponding B's . > > this->A->findAll() works OK. > > I can specify fields from A > > this->A->findAll(null,"A.ID"); > > I've got only ID from A and a list of all B's > > Now I want to specify fields from B. > > this->A->findAll(null,"B.ID"); > > It doesn't work. It's a SQL error, becasue Cake makes : > "SELECT ...FROM 'a' as 'A' WHERE . " > and there's no such collumn : "B.ID" > > Is it possible to specify fields in hasMany relation ? --~--~-~--~~~---~--~~ 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: findAll with specific fields and hasMany relation
i guess you have to use belongsTo for B model. On May 8, 4:46 pm, peper <[EMAIL PROTECTED]> wrote: > Hi, > > Let's say I've got two models A and B , and the relation is > A hasMany B > > Now I want to "findAll" A's with corresponding B's . > > this->A->findAll() works OK. > > I can specify fields from A > > this->A->findAll(null,"A.ID"); > > I've got only ID from A and a list of all B's > > Now I want to specify fields from B. > > this->A->findAll(null,"B.ID"); > > It doesn't work. It's a SQL error, becasue Cake makes : > "SELECT ...FROM 'a' as 'A' WHERE . " > and there's no such collumn : "B.ID" > > Is it possible to specify fields in hasMany relation ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
findAll with specific fields and hasMany relation
Hi, Let's say I've got two models A and B , and the relation is A hasMany B Now I want to "findAll" A's with corresponding B's . this->A->findAll() works OK. I can specify fields from A this->A->findAll(null,"A.ID"); I've got only ID from A and a list of all B's Now I want to specify fields from B. this->A->findAll(null,"B.ID"); It doesn't work. It's a SQL error, becasue Cake makes : "SELECT ...FROM 'a' as 'A' WHERE . " and there's no such collumn : "B.ID" Is it possible to specify fields in hasMany relation ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---