I have two models:
User
Post
User HABTM Post
Post HABTM User
How can I find the users with the most posts since a specified date?
Actually I have a third model PostsUser, which I implemented, to try a
few things. I can already find the users with the most posts, by doing
the following:
$this->User->bindModel(array('hasOne' => array('PostsUser')));
$users = $this->User->find('all', array(
'recursive' => 0, //int
'fields' => array('*','COUNT(PostsUser.post_id) AS num'),
'group' => 'User.id',
'order' => 'num DESC',
'limit' => 10 //I onlyneed the top10
));
All I need is a way to only count the posts with post.created>
[given_date]
Any ideas?
Thanks
Donnerbeil
--~--~---------~--~----~------------~-------~--~----~
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