The *other* only benefit is that you're storing your business logic in
your business entities where it belongs, demonstrating better
encapsulation and reducing the likelihood of code duplication.
On Nov 26, 10:12 am, mbavio <[EMAIL PROTECTED]> wrote:
> Instead of making an if, you can put that code in an afterSave
> callback. But it´s the same, the olny benefit will be that you are
> following the Fat Model, Skinny Controller concept.
>
> Cheers. Martin Bavio.
>
> On Nov 24, 10:21 pm, josoroma <[EMAIL PROTECTED]> wrote:
>
> > In my benchlink_controller.php im saving the benchlink model data and
> > the report model data associated.
>
> > function add() {
>
> > if (!empty($this->data)) {
>
> > $this->cleanUpFields();
>
> > $this->Benchlink->create();
>
> > if ($this->Benchlink->save($this->data)) {
>
> > $this->data['Report']['id'] =
> > $this->Benchlink->getLastInsertId();
>
> > $this->Report->save($this->data);
>
> > $this->Session->setFlash('The Benchlink has
> > been saved');
> > $this->redirect(array('action'=>'index'),
> > null, true);
>
> > } else {
>
> > $this->Session->setFlash('The Benchlink
> > could not be saved.
> > Please, try again.');
>
> > }
> > }
> > }
>
> > There exists a better way, maybe using aftersaving?
>
> > Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---