I'm having a problem with sorting the recordset with order by and
group by statements. Would appreciate any help.
There are 2 models, Team and Vote (Team has many Votes) and I want to
order teams based on the number of votes they got.
Here's the find call:
$teams = $this->find('all', array('fields' => 'Vote.team_id', 'order'
=> 'COUNT('Vote.team_id'), 'group' => 'Vote.team_id'));
At the moment there' s only one team in the database with 3 votes.
However, the above query returns 2 (duplicate) records but when I
place the same query directly in the mysql it works as expected and I
get only one.
Any ideas?
thank you
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment