I'm having a problem adding more than one player to a team. When I try to insert more than one player it only updates the first inserted entry which belongs to the team.
But let's start at the beginning: When I call find on a team with several players (added directly in the db) I get the following:
Array
(
[Team] => Array
(
[id] => 3
...
)
[Player] => Array
(
[0] => Array
(
[id] => 15
....
)
[0] => Array
(
[id] => 21
....
)
[0] => Array
(
[id] => 23
....
)
....
)
)
So I thought I could save it just in that format in to the db. But like I said before the first entry is inserted and then updated with the other id's and I have no idea why. Shouldn't it be just like always that you could save the same structure of data like you get out of the find?
Here is my HABTM relation in the Team Model:
public $hasAndBelongsToMany = array(
'EmployeesSecondary' => array(
'className' => 'Player',
'joinTable' => 'employees_teams',
'foreign_key' => 'team_id',
'associationForeignKey' => 'bv',
'unique' => 'keepExisting'
)
);
I have already tried using saveAll() (only have on saveAll-call), changed the unique behaviour. I even inserted some test data into the habtm-table and tried saving what I got out from find('all') directly back into the database but it only updates every entry after the first is inserted.
Any idea would be appreciated.