Hi,
I frequently need to verify that deleting a record is allowed. I was
wondering how others handle this kind of "conditional delete"?

When finding I can very simply add on an extra condition to check that
some field matches my requirement. Using the common Blog-analogy it
might be finding only published posts (published = 1) or similar
"static" requirement.

For deletes I have nothing similar to check, say, published = 0 so
that I don't delete published posts for example. It might be to
disallow deleting of users with admin privileges and a number of other
fairly common cases.

A good example would be a "Folder hasMany dependent File" (these are
reserved words but as a meta-example). When deleting a Folder the user
doing the deleting needs write access to the folder and each file
needs to "beforeDelete" each physical file before deleting the
database record.

deleteAll will not work here (afaik) since I need the callbacks to
fire on the dependent model and I need a condition on the primary
model.

I first have to "find" to verify if the delete can take place, which
is extra queries (and for-loops). Is there an option better than using
find('list'), foreach and del ?


/Martin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to