1 <?php
2
3 4 5 6 7 8 9 10 11
12
13 MainFactory::load_class('OrderItemPropertyRepositoryWriterInterface');
14
15 16 17 18 19 20 21
22 class OrderItemPropertyRepositoryWriter implements OrderItemPropertyRepositoryWriterInterface
23 {
24
25 26 27 28
29 protected $db;
30
31
32 33 34 35 36
37 public function __construct(CI_DB_query_builder $dbQueryBuilder)
38 {
39 $this->db = $dbQueryBuilder;
40 }
41
42
43 44 45 46 47 48 49 50
51 public function insertIntoOrderItem(IdType $orderItemId, OrderItemProperty $orderItemProperty)
52 {
53 $orderItemPropertyArray = array(
54 'orders_products_id' => $orderItemId->asInt(),
55 'properties_name' => $orderItemProperty->getName(),
56 'values_name' => $orderItemProperty->getValue(),
57 'properties_price_type' => $orderItemProperty->getPriceType(),
58 'properties_price' => $orderItemProperty->getPrice(),
59 'products_properties_combis_id' => $orderItemProperty->getCombisId()
60 );
61
62 $this->db->insert('orders_products_properties', $orderItemPropertyArray);
63
64 return $this->db->insert_id();
65 }
66
67
68 69 70 71 72 73 74
75 public function update(StoredOrderItemProperty $orderItemProperty)
76 {
77 $orderItemPropertyArray = array(
78 'properties_name' => $orderItemProperty->getName(),
79 'values_name' => $orderItemProperty->getValue(),
80 'properties_price_type' => $orderItemProperty->getPriceType(),
81 'properties_price' => $orderItemProperty->getPrice(),
82 'products_properties_combis_id' => $orderItemProperty->getCombisId()
83 );
84
85 $this->db->update('orders_products_properties', $orderItemPropertyArray,
86 array('orders_products_properties_id' => $orderItemProperty->getOrderItemAttributeId()));
87
88 return $this;
89 }
90 }