I am trying to update tables with a has and belongs to many (HABTM) relationship.
When my join table looked like this:
CREATE TABLE IF NOT EXISTS `items_labels` (
`item_id` int(11) NOT NULL,
`label_id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I use CakePHP, so I could update the tables with $this->Item->save($data) where $data was:
Array
(
[Item] => Array
(
[id] => 1
)
[Label] => Array
(
[Label] => Array
(
[0] => 4
[1] => 5
[2] => 7
[3] => 8
)
)
)
I've added a column to my join table, so it now looks like:
CREATE TABLE IF NOT EXISTS `items_labels` (
`item_id` int(11) NOT NULL,
`label_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
When I am saving $data, I also want to save a user id. The user id will be the same for all records in a single save operation.
Can someone help me understand what the $data array needs to look like in order to incorporate the user id? Thanks.