Skip to content

Instantly share code, notes, and snippets.

@brandoncordell
Created February 29, 2012 14:37
Show Gist options
  • Save brandoncordell/1941247 to your computer and use it in GitHub Desktop.
Save brandoncordell/1941247 to your computer and use it in GitHub Desktop.
saving habtm, many associated records at a time
<?php
// saving habtm, many associated records at a time
// Audit hasAndBelongsToMany User
// table: audits_users
$audit = array(
'Audit' => array(
'name' => 'My Audit',
'start_date' => '2012-02-10,
'end_date' => '2012-03-10'
)
);
$users = array(
array(
'id' => 12,
'id' => 14,
'id' => 15,
'id' => 16
)
);
$this->data['Audit'] = $audit;
$this->data['User'] = $users;
$this->Audit->save($this->data);
?>
@rchavik
Copy link

rchavik commented Feb 29, 2012

$this->data['User'] = array('User' => 12, 14, 15, 16))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment