Re: find if exists any hasmany relationship
thanks On Mar 22, 5:39 am, WebbedIT wrote: > Are you wanting an INNER JOIN so it will only find records where Poll > has Section and has Question. > > If this is the case then I would define counterCache true on your > Section and Question belongsTo associations and add a section_count > and question_count field to you polls and sectios tables respectively. > > This way when running a find on Poll you can add the conditions of > Poll.section_count > 0 and Section.question_count > 0. However to do > this you would also have to use bindModel to change your Poll hasMany > Section to Poll hasOne Section. > > HTH > > Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Re: find if exists any hasmany relationship
Are you wanting an INNER JOIN so it will only find records where Poll has Section and has Question. If this is the case then I would define counterCache true on your Section and Question belongsTo associations and add a section_count and question_count field to you polls and sectios tables respectively. This way when running a find on Poll you can add the conditions of Poll.section_count > 0 and Section.question_count > 0. However to do this you would also have to use bindModel to change your Poll hasMany Section to Poll hasOne Section. HTH Paul. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Re: find if exists any hasmany relationship
Look into using the Containable behaviour, that will make it easier for you in the future, when finding related data. http://book.cakephp.org/view/474/Containable The Poll find will then include the contain array - example: [example] 'contain' => array( 'Section' => array( 'Question' ) ) [/example] The above will give you all the Poll records with all the related Section records and for each Section all the related Question records. Enjoy, John On Mar 22, 3:35 am, stefano wrote: > Hello > > I have a question about find('all') i need get all the records that > have any relation in the database for example > > polls hasmany sections > sections hasmany questions > > i need all the polls that have any sections and this section have any > questions > > any idea how do that using the cake's way? > > s. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
find if exists any hasmany relationship
Hello I have a question about find('all') i need get all the records that have any relation in the database for example polls hasmany sections sections hasmany questions i need all the polls that have any sections and this section have any questions any idea how do that using the cake's way? s. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.