Oh, I forgot, here is SQL dump: SELECT COUNT(*) AS `count` FROM `products` AS `Product` WHERE `Product`.`id` = 3 UPDATE `products` SET `id` = 3, `name` = 'ddd', `description` = '', `price` = 5.00, `special_price` = 6.00, `quantity` = 7, `weight` = 10.00, `active` = 1, `modified` = '2008-10-09 19:57:14' WHERE `products`.`id` = 3 INSERT INTO `categories_products` (`category_id`,`quantity`,`price`) VALUES (2,54,10.00) SELECT LAST_INSERT_ID() AS insertID
Looks perfect, isn't it? And when I refresh page I see flash message: "The Product has been saved" But when I look into database of course is not updated. Weird... On 9 Paź, 19:30, red <[EMAIL PROTECTED]> wrote: > Hello all, > I'm getting something strange with HABTM relations. I follow > instruction from > here:http://teknoid.wordpress.com/2008/09/24/saving-extra-fields-in-the-jo... > > Now, two examples: > > When I'm creating new Product this works perfect: > $this->Product->bindModel(array('hasMany' => > array('CategoriesProduct'))); > $this->Product->saveAll($this->data) > > Debug for $this->data: > Array > ( > [Product] => Array > ( > [name] => ddd > [description] => > [price] => 5.00 > [special_price] => 6.00 > [quantity] => 7 > [weight] => 10.00 > [active] => 1 > ) > > [CategoriesProduct] => Array > ( > [0] => Array > ( > [category_id] => 2 > [quantity] => 55 > [price] => 10.00 > ) > > ) > > ) > > But when I'm updating existing Product with same code I'm getting: > Notice (8): Undefined index: CategoriesProduct [CORE/cake/libs/model/ > model.php, line 1425] > Model::saveAll() - CORE/cake/libs/model/model.php, line 1425 > ProductsController::manager_edit() - APP/controllers/ > products_controller.php, line 140 > > The debug for $this->data (the difference is of course that here is > defined id for Product): > Array > ( > [Product] => Array > ( > [id] => 3 > [name] => ddd > [description] => > [price] => 5.00 > [special_price] => 6.00 > [quantity] => 7 > [weight] => 10.00 > [active] => 1 > ) > > [CategoriesProduct] => Array > ( > [0] => Array > ( > [category_id] => 2 > [quantity] => 55 > [price] => 10.00 > ) > > ) > ) > > What I'm missing? Help! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
