$this->Article->bindModel(array(
  'hasOne' => array(
    'ReviewCount' => array(
      'className' => 'Review',
      'fields' => 'COUNT(ReviewCount.id) AS review_count'
    )
  )
));
$articles = $this->Article->find('all', array(
  'group' => 'Article.id',
  'order' => 'review_count DESC'
));

hth
grigri

On Oct 4, 1:50 am, "Matthew Camuto" <[EMAIL PROTECTED]> wrote:
>  Apologies in advance. GMAIL auto-sent my last emal before finishing!!!!!
>
> hi there
>
> thsi group is great firstly and i have been doing pretty well with cake.
> however i was trying something that is either
>
> absurdly simple or not possible. i want to get my model out (via db) but i
> want to sort it based on the count of a set
>
> of children (has many). The simplist example is
>
> Article
>
> has many Reviews
>
> And I want to retrieve all the articles orderd solely on Review count. I was
> not sure if I could do this strictly through
>
> query or in a combo of a query along with the 'Set' helper class or if I
> would have to write my complete own sorting function..
>
> Thanks in advance
>
> matt
--~--~---------~--~----~------------~-------~--~----~
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