class OrderProduct extends AppModel {
   var $name = 'OrderProduct';
   var $useTable = 'orders_products';
   var $primaryKey = 'orders_products_id';

   function generate_order_product_record($contents, $order_id)
   {
                foreach ($contents as $product){
                ///var_dump($product);
                $order_product['OrderProduct']['orders_id'] = $order_id;
                $order_product['OrderProduct']['products_id'] = $product['id'];
                $order_product['OrderProduct']['products_model'] = 
$product['model'];
                $order_product['OrderProduct']['products_name'] = 
$product['name'];
                $order_product['OrderProduct']['products_price'] = 
$product['price'];
                $order_product['OrderProduct']['final_price'] = 
$product['price'];
                $order_product['OrderProduct']['products_tax'] = 0.00;
                $order_product['OrderProduct']['products_quantity'] =
$product['quantity'];
                var_dump($order_product);
                $order_product_result = $this->save($order_product);
                var_dump($this->getLastInsertId());
        }
   }
}


$contents = array(
  1 =>
    array
      'id' => int 8891
      'name' => string 'testtetet' (length=9)
      'model' => string 'mv0blu1024mp092' (length=15)
      'image' => string 'ux_mv0blu1024mp092_ux_' (length=22)
      'price' => float 1
      'quantity' => int 5
      'weight' => float 0.3
  2 =>
    array
      'id' => int 5614
      'name' => string '1GB  MICRO SD MEMORY CARD TransFlash TF' (length=39)
      'model' => string 'a07030700ux0005' (length=15)
      'image' => string 'ux_a07030700ux0005_ux_' (length=22)
      'price' => float 15.99
      'quantity' => int 1
      'weight' => float 0.04
)

$this->OrderProduct->generate_order_product_record($contents, '123')

why first sql statement is insert,second is update,i want to all is insert.
please help me!

--~--~---------~--~----~------------~-------~--~----~
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