this should be possible in theory if you use 'NOT' and 'OR' as part of
your find conditions, maybe with 'order'=>'RAND()' and 'limit'=>20.
please refer to
http://book.cakephp.org/view/74/Complex-Find-Conditions

CounterCache  might be good for the first part of your problem.
http://book.cakephp.org/view/816/counterCache-Cache-your-count
- no belonging entries in B

good luck

On May 20, 9:50 am, Martin Westin <[email protected]> wrote:
> Containable is "only" a kind of selective recursion. It does handle
> conditions on your associated models but that will only limit the data
> returned from that model... not from the main one. In short: it is not
> like a join.
>
> For your type of query you either have to do a join or "fumble around"
> with the result set.
>
> If you haven't done joins in Cake before, check out the code in Nate's
> bakery article for some good example 
> usage:http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-...
>
> /Martin
>
> On May 20, 12:18 pm, Günther Theilen <[email protected]> wrote:
>
> > Hi,
>
> > I'm a little bit lost about how to shape my query with the containable
> > behaviour.
>
> > There are two models:
> > A hasMany B
> > B belongsTo A
>
> > B has a date-field
>
> > Now I'd like to get one random data set out of A which has either
> > - no belonging entries in B
> > or
> > - only entries in B where date is more than 1 month ago
>
> > Is this even possible with Containable or do I have to do several
> > queries and fumble around afterwards with PHP?
>
> > Regards
> > Guenther
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to