CounterCache?
Depends on the relationship you are using and a few other bits but if
you want to keep track of how many topis a forum has then it should
work for you.

http://book.cakephp.org/view/490/counterCache-Cache-your-count


On Mar 26, 3:36 pm, "designv...@gmail.com" <designv...@gmail.com>
wrote:
> I have written this:
>
>         function afterSave($created) {
>             if($created == true) {
>                 $forum_id = $this->Topic->field('forum_id', array('Topic.id'
> => $this->data['Post']['topic_id']));
>                 $forum_posts = $this->Topic->Forum->field('post_count', array
> ('Forum.id' => $forum_id));
>                 $this->Topic->Forum->saveField('post_count', $forum_posts +
> 1);
>             }
>         }
>
> And it works fine, but... is it the best 'Cake' way of doing this?
>
> TIA
> t.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to