You were right of-course. I don't know what I messed up when I first
tried using deleteAll but it works as I expect it now with callbacks
and all.

thanks
Martin

On Apr 14, 7:15 pm, Martin Westin <[email protected]> wrote:
> Hm... thought I had...
> I'll give it another try.
>
> On Apr 14, 2:01 pm, grigri <[email protected]> wrote:
>
> > Looking at the signature for `deleteAll` should answer your question:
>
> > > function deleteAll($conditions, $cascade = true, $callbacks = false)
>
> > In the version of cake I'm using, it does say in the comments that
> > $callbacks is "not being used", but a quick view of the code shows
> > that it is.
>
> > If you enable both $cascade and $callbacks you should get the effect
> > you're looking for.
>
> > hth
> > grigri
>
> > On Apr 14, 12:28 pm, Martin Westin <[email protected]> wrote:
>
> > > 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