Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. Array
  2. (
  3. [Order] => Array
  4. (
  5. [user_email] => st@kr.com
  6. [billing_first] => Steve
  7. ... //more excluded
  8. [total] => 5000
  9. )
  10.  
  11. [Product] => Array
  12. (
  13. [0] => Array
  14. (
  15. [id] => 1
  16. [price] => 5000.00
  17. [quantity] => 1
  18. )
  19.  
  20. )
  21.  
  22. )
  23.  
  24. Notice (8): Undefined index: id [CORE/cake/libs/model/model.php, line 1391]
  25.  
  26. Model::__saveMulti() - CORE/cake/libs/model/model.php, line 1391
  27. Model::save() - CORE/cake/libs/model/model.php, line 1355
  28. Model::__save() - CORE/cake/libs/model/model.php, line 1778
  29. Model::saveAll() - CORE/cake/libs/model/model.php, line 1673
  30. CartsController::saveOrder() - APP/controllers/carts_controller.php, line 128
  31. CartsController::checkout() - APP/controllers/carts_controller.php, line 172
  32. Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
  33. Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
  34. [main] - APP/webroot/index.php, line 83
  35.  
  36. if ($this->Order->save($this->data)) {
  37. for($i=0; $i<sizeof($this->data['OrderProduct']); $i++){
  38. $this->data['OrderProduct'][$i]['order_id'] = $this->Order->id;
  39. }
  40. $this->Order->OrderProduct->saveAll($this->data['OrderProduct']);
  41. }
  42.  
  43. $this->Order->create();
  44. $this->Order->unBindModel(array('hasAndBelongsToMany'=>array('Product')));
  45. $f = $this->Order->save($this->data,false);
  46.  
  47. /* Save extra columns in HABTM TABLE */
  48. $this->Order->bindModel(array('hasMany'=>array('OrderProduct')));
  49. $q = array();
  50. if (!isset($this->data['Product']))
  51. {
  52. $v = false;
  53. }
  54. else
  55. {
  56. $v =true;
  57.  
  58. for($i=0;$i<count($this->data['Product']);$i++)
  59. {
  60. $this->data['OrderProduct'][$i]['order_id'] = $this->Order->getLastInsertID();
  61. $this->data['OrderProduct'][$i]['product_id'] = $this->data['Product'][$i];
  62. $this->data['OrderProduct'][$i]['quantity'] = $this->data['quantity'][$i];
  63. $this->data['OrderProduct'][$i]['state_id'] = $this->data['State'][$i];
  64. }
  65. }
  66.  
  67. $s = $this->Order->OrderProduct->saveAll($this->data['OrderProduct']);
  68.  
  69. $this->Order->unbindModel(array('hasAndBelongsToMany' => array('Product')));
  70.  
  71. $this->Order->bindModel(array('hasMany' => array('OrdersPost')));
  72.  
  73. $this->data['Order']['id'] = '1';
  74. $this->data['OrdersPost'][0]['product_id'] = '15';
  75. $this->data['PostsTag'][0]['price'] = '5000.00';
  76. $this->data['PostsTag'][0]['quantity'] = '1';
  77. $this->data['OrdersPost'][1]['product_id'] = '16';
  78. $this->data['PostsTag'][1]['price'] = '4000.00';
  79. $this->data['PostsTag'][1]['quantity'] = '2';
  80.  
  81. $this->Order->saveAll($this->data);
  82.  
  83. CREATE TABLE orders_products (
  84. id integer,
  85. order_id integer,
  86. product_id integer,
  87. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement