Hope this helps: 
http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part-1-working-with-multiple-models/

On Sep 1, 8:25 am, klaus <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm a little stuck with a feature I want to implement. I'm also new to
> cakePHP, so please help me with this one.
>
> I want to write into a changelog-table the changes made by a
> Submitter.
> The main model:
> class Adresse extends AppModel {
>     var $name = 'Adresse';
>
>         var $hasMany = 'Adressenchangelog';
> --- snip ---
>
> The changelog-model:
> class Adressenchangelog extends AppModel {
>     var $name = 'Adressenchangelog';
>
>         var $belongsTo = 'Adresse';
>
> }
>
> The controller-part of "Adressen":
> "
> if($this->Adresse->saveAll($this->data, array('validate'=>'first')))
> {
> "
>
> I want to pack this into beforeSave(), but I am stck with something
> more basic.
> How do I need to append this Information to $this->data?
>
> The static-Test is not working:
> "
> $this->data['Adressenchangelog'] = array('adresse_id' => 
> $this->data['Adresse']['id'], 'user_realname' => 'jaja');
>
> if($this->Adresse->saveAll($this->data, array('validate'=>'first')))
> {
> "
>
> And this one neither:
> "
> $this->data['Adresse']['Adressenchangelog'] = array('adresse_id' =>
> $this->data['Adresse']['id'], 'user_realname' => 'jaja');
> if($this->Adresse->saveAll($this->data, array('validate'=>'first')))
> {
> "
>
> So I really dont know how to start here.
>
> Thanks in advance
> klaus
>
> PS: If I execute this, it will work, but this is not within a
> transaction:
> $this->data['Adresse']['Adressenchangelog'] = array('adresse_id' =>
> $this->data['Adresse']['id'], 'user_realname' => 'jaja');
> if($this->Adresse->save($this->data))
> {
>         $this->Adresse->Adressenchangelog->save($this->Adresse-
>
> >Adressenchangelog->data);
--~--~---------~--~----~------------~-------~--~----~
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