well you won't be adapting $this->Model->del() i hope but what you
could do is this:

..in your controller action:

//if record was deleted succesfully
if($this->Model->delete($this->Model->id))
{
         //if image unlinks succesfully
        if(unlink($image))
        {
                 //success
        }

        else
        {
                //image failed to unlink
        }
}
//else record did not delete
else
{
           //record failed to delete
}

i personally would stuff this logic into my model and call it like
this:
$this->Model->myDeleteFunction($data)

you would have to change every reference to $this->Model->function()
to $this->function()
when using the code in the model.

that would allow you to reuse to logic in any controller that uses the
associated models thus keeping your controllers nice and skinny.

On Jul 28, 9:03 pm, bberg <[email protected]> wrote:
> hi
> i have a "posts" table with an image field.
> it stores just the filename as a varchar of course.
> how can i adapt the "delete" action so it also unlinks the image?
> thanks
--~--~---------~--~----~------------~-------~--~----~
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