I have a User model with two relations:
HasAndBelongsToMany
public $hasAndBelongsToMany = array( 'group' => array( 'className' => 'group', 'foreignKey' => 'user_id' ) );
HasMany
public $hasMany = array( 'phonenumber' => array( 'className' => 'phonenumber', 'foreignKey' => 'user_id' ) );
Phonenumber and Group have set
public $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id'
)
);
When I use
$this->saveAll(array(
'User' => $data,
'phonenumber' => $numbers, //array with data
'group' => $groups //array with data
)
);
The data gets saved in the tabels but User_id is "0" in phonenumber and group table.
How can I get the correct ID saved ? (CakePHP v 2.5)