After spinning my wheels for a few hours on this one, any help would be very
appreciated...
I have an 'Item' model:
class Item extends AppModel {
var $name = 'Item';
var $hasAndBelongsToMany = 'Label';
}
A 'Label' model:
class Label extends AppModel {
var $name = 'Label';
var $hasAndBelongsToMany = 'Item';
}
And an 'items_labels' join table:
CREATE TABLE `items_labels` (
`item_id` int(11) NOT NULL,
`label_id` int(11) NOT NULL,
`created` datetime default NULL
);
I cannot figure out how to save a simple record (association) to the join
table. I just don't understand what I need to put in my
'labels_controller.php' to get this result, for example:
INSERT INTO `database_name`.`items_labels` (`item_id`, `label_id`,
`created`) VALUES ('1', '1', NOW());
After many failed attempts, I'm back to an empty action:
function update($item_id, $label_id) {
}
In addition to save(), help with delete() would also be appreciated.
And not sure if it has any bearing on the solution, but for this action, I
am not concerned with any of the records in the 'items' or 'labels' tables.
Many thanks!
-Ryan
--
View this message in context:
http://n2.nabble.com/not-understanding-simple-HABTM-save-delete-tp1377073p1377073.html
Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---