I have a problem with my HABTM
table.
This is the model structure: Team <- EmployeesTeam -> EmployeesAdditionalData
'EmployeesSecondary' => array(
'className' => 'EmployeesAdditionalData',
'joinTable' => 'employees_teams',
'foreign_key' => 'team_id',
'associationForeignKey' => 'bv'
)
(bv is some sort of an Employee ID)
Everytime I try to save data in the HABTM Table with $this->Team->save()
as well as $this->Team->EmployeesTeam->save()
it saves the first entry perfectly, but then assumes, that the team_id would be the primary_key (even when I set the bv as PK or erase the whole primary index).
So, when I try to assign another Employee to the Team it updates the first entry and doesn't insert a new one.
INSERT INTO `employees_database`.`employees_teams` (`bv`, `team_id`) VALUES (3781, 3);
UPDATE `employees_database`.`employees_teams` SET `bv` = 3345, `team_id` = 3 WHERE `employees_database`.`employees_teams`.`team_id` = '3'
Is there something I'm doing wrong?