In my case I have a table of user ratings called Ratings. When a user
submits a rating it is stored using $this->Ratings->save() from the
controller. The next step in the controller is to update a second
table called Stats. This table store composite information about the
ratings (max, min, avg, etc). Each row in the Stats table is not
related to any particular row in the Ratings table. It is updated via
an insert query and pulls it's data from several rows in the Ratings
table.
Currently, I am calling $this->Ratings->save() in the controller
followed by $this->Stats->update(). This works but I thought it might
be better if I could call $this->Stats->update() in the afterSave
callback.
I think it is cleaner in this case to keep the two calls in the controller like you are currently doing. I don't think it makes sense to move it to the model unless there is a relationship. Someone else may have a different opinion, but I think the save followed by the update is the way to go.
The sats table seems to be acting as a cache for calculations based on the ratings. So I would view it as a cache instead of a model, even though you are using a model to implement your cache.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
