You have to add index like Part.0.name etc. .. see in the cookbook

W dniu 2010-08-10 13:38, Petr Vytlačil pisze:
Hi I need save data to order and orders_items and orders_parts, i try
use:
$this->Order->OrdersPart->save() or $this->Order->saveAll()

this array:

Array
(
    [0] => Array
        (
            [Order] => Array
                (
                    [id] => 1
                )

            [Part] => Array
                (
                    [Part] => Array
                        (
                            [item_id] => 20
                            [name] => BOLT,FLANGED,9X90
                            [code] => 92153-1610
                            [price] => 43647.00
                            [count] => 3
                        )

                )

        )
)

---
But this dont save data
THX

Model tables:

orders HABTM items or parts

CREATE TABLE IF NOT EXISTS `orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mailingaddress_id` int(11) DEFAULT NULL,
  `billingaddress_id` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `state` int(11) DEFAULT NULL,
  `note` varchar(255) COLLATE utf8_czech_ci DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_orders_users1` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci
AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `orders_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `item_id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(60) COLLATE utf8_czech_ci DEFAULT NULL,
  `price` decimal(6,2) NOT NULL,
  `count` int(11) NOT NULL,
  PRIMARY KEY (`id`,`item_id`,`order_id`),
  KEY `fk_items_has_orders_items1` (`item_id`),
  KEY `fk_items_has_orders_orders1` (`order_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci
AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `orders_parts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `order_id` int(11) NOT NULL,
  `part_id` int(11) NOT NULL,
  `name` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `code` varchar(100) COLLATE utf8_czech_ci NOT NULL,
  `price` decimal(6,2) NOT NULL,
  `count` int(11) NOT NULL,
  `type` int(11) NOT NULL,
  PRIMARY KEY (`id`,`order_id`,`part_id`),
  KEY `fk_orders_has_parts_orders1` (`order_id`),
  KEY `fk_orders_has_parts_parts1` (`part_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci
AUTO_INCREMENT=1 ;

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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


--
z poważaniem
Marek Wojciech Urbanowicz

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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

Reply via email to