Adam Royle wrote:
> If you want to sort on the column as well, I suggest you create a
> "counter cache". Basically, you store the count of subitems in a field
> in the main table, which is updated on create/update/delete.
>
> There is even a behaviour that can do this automatically for you.
>
> http://bakery.cakephp.org/articles/view/countercache-or-counter_cache-behavior

1.2 has that functionality built in now (not sure since when, but I've
been using it for a few months I think).

e.g.
<?php
class Comment extends AppModel {
        var $belongsTo = array(
                'Blog' => array(
                        'counterCache' => true,
                        'counterScope' => array('Comment.status' => '> 0')
                )
        );
}
?>

hth,

AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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