Actually I had made a mistake!! Forgot to add:
$this->Topic->Forum->id = $forum_id; Before the Save ooops! On Mar 26, 4:45 pm, designvoid <designv...@gmail.com> wrote: > 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 <martin.westin...@gmail.com> 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, "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 -~----------~----~----~----~------~----~------~--~---