There is!

The correct way is to set
$this->data['Tag'][0] = array(
                                           'tag_id' => $foo,
                                           'tagger_id' => $bar
                                         );

Does this seem unintuitive to anyone else?
I think updating the CakePHP Book with saving and retrieving join
table data would be very helpful, as this information is hard to find

On Mar 4, 10:30 pm, Omi <omi.chowdh...@gmail.com> wrote:
> I've searched through the groups and web, but I can't find any mention
> of SAVING to the model, only reading from it.
>
> Some example Models:
>
> Recipes HABTM Tags
> The "recipies_tags" table has an extra column which is "tagger_id"
>
> I have tried setting the value in $this->data before the save but this
> doesn't propagate back to the DB - the HABTM saves with the third
> column empty
> (I tried:
>  $this->data['RecipiesTag']['tagger_id']
>  $this->data['Tag']['RecipiesTag']['tagger_id']
>  $this->data['Recipie']['RecipiesTag']['tagger_id']
>  - are there any more locations I should try?)
>
> I did find a way of saving to the third column, but it seems pretty
> hacky:
>
> $recipiestag = $this->Tag->RecipiesTag->find('first', array
> ('conditions' => array(
>                                                                               
>                                                                               
>                                             'RecipiesTag.tag_id' => 
> $this->data['Tag']
> ['tag_id'],
>                                                                               
>                                                                               
>                                             'RecipiesTag.user_id' => 
> $this->data['User']
> ['id']
>                                                                               
>                                                                               
>                                     )
>                                                                               
>                                                                           )
>                                                                               
>                                           );
>
> $this->Tag->RecipiesTag->id = $recipiestag ['RecipiesTag']['id'];
> $this->Tag->RecipiesTag->saveField('tagger_id', $user_id);
>
> Is there a better way of doing this?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to