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 since it properly executes. Has anyone
run into this? Am I doing something wrong?

Thanks,
-mike

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



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
other files from the filesystem. With a cached file, it shouldn't be a
big deal if it's removed but (for whatever reason) the model delete
doesn't happen. That would suck with images or other files.

On Mon, Apr 6, 2009 at 7:10 AM, Mike mikerog...@gmail.com wrote:

 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 since it properly executes. Has anyone
 run into this? Am I doing something wrong?

 Thanks,
 -mike

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



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() callback
 would be better used (AFAIK) where you need to, say, remove images or
 other files from the filesystem. With a cached file, it shouldn't be a
 big deal if it's removed but (for whatever reason) the model delete
 doesn't happen. That would suck with images or other files.

 On Mon, Apr 6, 2009 at 7:10 AM, Mike mikerog...@gmail.com wrote:

  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 since it properly executes. Has anyone
  run into this? Am I doing something wrong?

  Thanks,
  -mike


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



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 it doesn't seem to be called when i delete
Member. Maybe I am doing something wrong?

p.s
sorry for my bad english :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



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 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 it doesn't seem to be called when i delete
 Member. Maybe I am doing something wrong?

 p.s
 sorry for my bad english :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



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)) {
$this-Session-setFlash(__('Contact deleted', true));
$this-redirect(array('action'='index'));
}
}

On 7 Sep, 23:23, seanislegend [EMAIL PROTECTED] wrote:
 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 because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



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));
                         $this-redirect(array('action'='index'));
                 }
                 if ($this-Contact-del($id)) {
                         $this-Session-setFlash(__('Contact deleted', true));
                         $this-redirect(array('action'='index'));
                 }
         }

 On 7 Sep, 23:23, seanislegend [EMAIL PROTECTED] wrote:

  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 because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



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 because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



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 helps.

Brain


On 7 Sep., 23:23, seanislegend [EMAIL PROTECTED] wrote:
 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 because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---