Did you try doing 'saveAll' ? You either have to save the models one at a time, or use the saveAll to save all the HABTM data at once as described here http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasMany-belongsTo
On Nov 17, 3:13 pm, Lukas <[EMAIL PROTECTED]> wrote: > Still, I cant make it work :( > > For testing, i have created 2 models abcbooks and abctags (abc is to > avoid conflict with existing models) > > http://bin.cakephp.org/saved/39693 Mysql dump, my model, controller > and view for this case > > 1.2.0.7692 RC3 from VERSION.TXT > > Let's say I want to add a new book with 2 new tags associated with it > > So i view I have > echo $form -> create(null, array('url' => 'add')); > OR > echo $form -> create(null, array('url' => 'addAll')); > for this->save and this0>saveAll in model > > echo $form->input('Abctag.0.title', array('label' => 'First > tag')); // I fill this one with best > echo $form->input('Abctag.1.title', array('label' => 'Second > tag')); // I fill this one with duper > > If I run > function add() { > $this -> Abcbook -> save($this -> data); > } > > MySQL dump returns > > 1 DESCRIBE `abcbooks` > 2 DESCRIBE `abctags` > 3 DESCRIBE `abcbooks_abctags` > 4 INSERT INTO `abcbooks` (`title`) VALUES ('Mooks') > 5 SELECT LAST_INSERT_ID() AS insertID > 6 SELECT `AbcbooksAbctag`.`id` FROM `abcbooks_abctags` AS > `AbcbooksAbctag` WHERE `AbcbooksAbctag`.`abcbook_id` = 6 > 7 INSERT INTO `abcbooks_abctags` (`abcbook_id`) VALUES (6) > 8 SELECT LAST_INSERT_ID() AS insertID > 9 INSERT INTO `abcbooks_abctags` (`abcbook_id`) VALUES (6) > 10 SELECT LAST_INSERT_ID() AS insertID > > As you can see, there even is no 'best' or 'super' mentioned, as I > filled my form with them > > If I run > > function addAll() { > $this -> Abcbook -> save($this -> data); > } > > 1 DESCRIBE `abcbooks` > 2 DESCRIBE `abctags` > 3 DESCRIBE `abcbooks_abctags` > 4 START TRANSACTION > 5 INSERT INTO `abcbooks` (`title`) VALUES ('Mooks') > 6 SELECT LAST_INSERT_ID() AS insertID > 7 COMMIT > > Not working either, > > So what I am doing wrong, or cakePHP's magic can't do what I need? > > Any ideas welcome ;) > Thank you --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
