This looks great, but unfortunately seems like not working here.
I altered my Comment model:
var $belongsTo = array(
'News' => array(
'className' => 'News',
'foreignKey' => 'news_id',
'conditions' => '',
'fields' => '',
'order' => '',
'counterCache' => true
));
Then in the news model I do finding by:
function get_last_paged($page) {
$offset = ($page - 1) * 5;
$result = self::find('all', array('limit' => 5, 'offset' =>
$offset));
return $result;
}
function get_last_commented($page) {
$offset = ($page - 1) * 5;
$result = self::find('all', array('limit' => 5, 'offset' =>
$offset,
'order' => 'News.comment_count DESC'));
return $result;
}
The last_paged function works, the commenting - doesn't.
Looking into the phpmyadmin seems like no changes are done.
Is there anything else to do for the comments?
On Apr 14, 12:02 pm, WebbedIT <[email protected]> wrote:
> I would recommend using counterCache if regularly sorting data by
> count, it's much more efficient hence why it;s included in Cake's
> automagic.
>
> http://book.cakephp.org/view/816/counterCache-Cache-your-count
>
> HTH
>
> Paul
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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