I am running into a problem where my join tables are not being updated
when I call saveAll. I have the latest stable version of cakephp, in
which this bug was fixed.
Here is the relevant action code:
//first update the ['Player'] array to replace username with ['User']
['id']
foreach ($this->data['Player'] as $key => $row) {
$this->data['Player'][$key]['campaign_id'] = $id;
if ($this->data['Player'][$key]['username'] != "") {
$this->data['Player'][$key]['User']['id'] = $this->User-
>field('id', array('User.username' => $this->data['Player'][$key]
['username']));
}
}
debug($this->data['Player']);
if ($this->Campaign->save($this->data)) {
if ($this->Player->saveAll($this->data['Player'])) {
$this->flash('Your campaign has been setup.', "/
campaigns/run/$id");
}
}
}
And the Player data that is in $this->data['Player'] (only showing the
first)
[0] => Array
(
[characterName] =>
[playerName] =>
[username] => testing
[baseExperienceSpent] =>
[overlord] => 0
[campaign_id] => 3
[User] => Array
(
[id] => 11
)
)
The way I understand it, this should cause my players_users table to
have a row inserted into it. However that is not happening. When I
do a find() on Player, it does return to me the associated Users, so
I'm pretty sure the model associations are setup correctly.
Thanks for any help you can offer.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment