I have recently come to terms on how cake deletes associated models
with the 'dependent' variable. This is a powerful but I feel that it
is hugely inefficient when it comes to deleting (especially a hasMany
relationship).
I have a few models whos afterSave and afterDelete callbacks
decriment/incriment a counter (much like how counterCache is 'supposed'
to be implemented). This is a huge concern because now I am updating a
parent model everytime a model is deleted.
Example Implementation (rough example): ForumPost (includes field
`view_count`) hasMany ForumPostView (belongsTo ForumPost->dependent =
true).
ForumPostView::afterSave() and ForumPostView::afterDelete() both call a
{model}->counterCache() that incriments/decriments the 'view_count'
based on their associated foreign key.
Now you can imagine what happens when I call ForumPost->del (1); and a
ForumPost has about 500 ForumPostViews. It will go through and delete a
ForumPost, then the callbacks will count(*) and save
ForumPost.view_count ...
See where I am coming from?
IMO, the best way to handle this is to hack in a afterMultiDelete()
callback thta I can control the functionality on a multiDelete..
Thoughts? Opinions?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---