afterDelete question

2009-04-06 Thread Mike
I have the following callback in my model: public function afterDelete() { Cache::delete('client_' . $this-field('name')); } Although $this-id is set, the field function (or any similar function, such as read(), find(), etc.) doesn't return any data. I've had to resort to beforeDelete

Re: afterDelete question

2009-04-06 Thread brian
It doesn't return anything because it's been deleted. Your model's ID may still be set but it no longer points to a row in the DB. So field() comes back empty. For your purposes, use beforeDelete(). The afterDelete() callback would be better used (AFAIK) where you need to, say, remove images or

Re: afterDelete question

2009-04-06 Thread Mike
Duh. Thanks Brian. -mike On Apr 6, 8:41 am, brian bally.z...@gmail.com wrote: It doesn't return anything because it's been deleted. Your model's ID may still be set but it no longer points to a row in the DB. So field() comes back empty. For your purposes, use beforeDelete(). The

afterDelete question

2009-02-25 Thread Deividas
I have two controller's, for example Members and MemberPictures, when I delete Member i want MemberPicture also deleted, i have set MemberPictures dependable in Member model, but I also want to unlink actual picture from the file system. I've tried using afterDelete() in MemberPicture model, but

Re: afterDelete question

2009-02-25 Thread dr. Hannibal Lecter
You are correct, model callbacks are not called for related models. You will probably have to handle that in Member::afterDelete(). On Feb 25, 8:57 am, Deividas deividas.sen...@gmail.com wrote: I have two controller's, for example Members and MemberPictures, when I delete Member i want

Re: afterDelete question

2008-09-08 Thread alkemann
function delete($id = null) { if (!$id) { $this-Session-setFlash(__('Invalid id for Contact', true)); $this-redirect(array('action'='index')); } if ($this-Contact-del($id)) {

Re: afterDelete question

2008-09-08 Thread seanislegend
Thanks for your suggestions, I've already got it working without afterDelete. Thanks. On Sep 8, 9:26 am, alkemann [EMAIL PROTECTED] wrote:         function delete($id = null) {                 if (!$id) {                         $this-Session-setFlash(__('Invalid id for Contact', true));  

afterDelete question

2008-09-07 Thread seanislegend
Hey, after I delete from a DB something I want to set a Flash message saying if it's successfully been deleted or if there was an error. I'm not sure how to implement this with afterDelete. Any ideas? Thanks. --~--~-~--~~~---~--~~ You received this message

Re: afterDelete question

2008-09-07 Thread Braindead
Hi, there is no need to use the afterDelete event, because the delete function of the model class gives a return value. Depending on the return value you can set the flash message. Pls. have a look at the API: http://api.cakephp.org/class_model.html#680f1a7876f7be4d87308d4df3252e77 I hope this