Use  $this->Orderitem->create(); as the first line on foreach
($cartitems as $ci) loop to initialize the model for a new record

-- 
Pablo Viojo
[EMAIL PROTECTED]
http://pviojo.net


On 8/1/07, apadzik <[EMAIL PROTECTED]> wrote:
>
> Hi! I got problem. I have tables: carts, carts_products, orders and
> orderitems. So, when the customer makes an order, the action make() in
> orders controller does the simple thing to create order for customer,
> then find all the products from the user's cart and save it to the
> orders orderitems table.
> The problem is that, when I save cartproducts to orderitems I do it in
> a loop:
>
> $cartitems=$this->CartsProduct->findAllByCartId($c_id);
>                                 foreach ($cartitems as $ci)
>                                 {
>                                         
> $this->data['Orderitem']['order_id']=$o_id;
>                                         
> $this->data['Orderitem']['product_id']=$ci['CartsProduct']
> ['product_id'];
>                                         
> $this->data['Orderitem']['size']=$ci['CartsProduct']['size'];
>                                         
> $this->data['Orderitem']['price']=$this->Product-
> >field('price',"id='".$ci['CartsProduct']['product_id']."'");
>                                         $this->Orderitem->save($this->data);
>                                 }
>
> When I "echo" all this data above ($cartitems, and $ci[..][..]) it
> shows me everything what's in the cart just like it's supposed to.
> When I echo "$this->Orderitem->save($this->data)" for all the
> cartproducts it gives me "1" as it was saved to orderitems table.
> So...........why in phpMyAdmin in my orderitems table I see only one
> product from cart and it is the last product added to cart??????
> Any1 help!:-)))) Please:-))
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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