Google Groups Home Help | Sign in
Message from discussion a few questions about cake 1.2
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Claudio Poli   
View profile
 More options Jan 23 2007, 11:11 am
From: "Claudio Poli " <masterk...@gmail.com>
Date: Tue, 23 Jan 2007 08:11:33 -0800
Local: Tues, Jan 23 2007 11:11 am
Subject: Re: a few questions about cake 1.2
hi Walker,
imagine you have a regular forum.
you will end up having categories, forums (and subforums, joined with
themselves), topics and posts.
you call the forum index page, go to a forum and display the number of
topics/posts in there.
without something like counterCache what do you do? make a findCount on
the fly? fetch every association recursively and do a count() in php?
no, it's better that when writing a new post or remove one to have a
field post_counter in Forum model that have this number for you.
same thing goes with other, like Topic, which you have the number of
posts in there.

This is useful also for User and Articles, when user write a new
Article the field article_count in model User gets automatically
updated with the new count of its articles, so you can use this value
when you want without fetching associations to make the count.

The way this behavior works is not like in rails, when they use
increment/decrement field, it's far more accurate because it has three
callbacks, one for inserting and two for deleting, and the updating of
fields is made with findCount.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google