I create several associations at a time, and there are several problems when it comes to saving.
I have the following code:
<?php
foreach($userData as $user) {
$data = array('User' => array('id' => $user['id']), 'Site' => array('id' => $user['site_id']));
$this->User->save($data);
}
?>
I experimented with formatting the data array in different ways, although I always run into the same problems. Either previous records are moved when a new one is inserted, or the current one is updated.
I could just use the following, although I need the behavior to run.
$this->User->SiteUser->save($data);
Edit: Also $ this-> User-> create (); doesn't seem to be doing much.
source
share