In my experience you can't do that. There are two options; (1) do the search from the related model and contain the primary model - this works but the array is a bit twisted, or (2) construct your find using joins (http://book.cakephp.org/view/1047/Joining-tables). Option 2 will give you exactly what you want but it's a bit fiddly constructing it.
I'd love to see an option added to the Contain behaviour that uses an inner join rather than a left join, which would solve this. On 22 Jun 2011, at 15:36, Michel wrote: > Hi everybody, > > I use CakePHP for quite some time now and I have stumpeld upon the > same problem several times. While using the conatainable behavior I > want to show a record only if a subrecord is present. For example: > Show only blog-posts WITH comments. > > any ideas? > > greetings, > Michel > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > To unsubscribe from this group, send email to > [email protected] For more options, visit this group at > http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
