Cheers for replying, I'm using counterCache for the belongsTo relationships, but this is for post count in the forum so its effectively 2 relationships away, so I kinda work my way back up to forum then increment the post count.
Its basically to stop myself using counts etc... As I said, it works fine, just had that nagging feeling there might be a better way! ;) t. On Mar 26, 3:15 pm, Martin Westin <[email protected]> wrote: > 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, "[email protected]" <[email protected]> > 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 [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 -~----------~----~----~----~------~----~------~--~---
