afterSave already contains "created/updated":
http://book.cakephp.org/view/684/afterSave
note the param passed

On 30 Sep., 16:35, psybear83 <[email protected]> wrote:
> Hello folks
>
> From Ruby On Rails I know the beforeCreate() and afterCreate() hooks
> of models. I didn't find them for CakePHP, so I implemented them
> myself:
>
>   function isNewRecord() {
>     return empty($this->id) || $this->field('created') == 
> $this->field('modified');
>
>   }
>
>   function beforeSave() {
>     if($this->isNewRecord()) {
>       return $this->beforeCreate();
>     }
>   }
>
>   function afterSave() {
>     if($this->isNewRecord()) {
>       return $this->afterCreate();
>     }
>   }
>
>   function beforeCreate() {
>     return true;
>   }
>
>   function afterCreate() {
>     return true;
>   }
>
> Sadly, this implementation depends on created and modified fields, and
> the isNewRecord() method itself isn't very beautiful, too. So maybe
> there is a better implementation?
>
> Thanks
> Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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