D
D
dro1d2016-03-22 13:23:13
Yii
dro1d, 2016-03-22 13:23:13

How to save item data in an order in Yii 1.16?

Good afternoon!
I am working on a shopping cart in Yii. There is an order entity in which information about the order is stored and a catalog in which goods are stored. There is a third table in the database:

CREATE TABLE yii_order_items (
  order_id int(11) NOT NULL COMMENT 'id заказа',
  good_id int(11) NOT NULL COMMENT 'Id товара',
  count varchar(255) DEFAULT NULL COMMENT 'количество товара',
  price varchar(255) DEFAULT NULL COMMENT 'цена',
  PRIMARY KEY (order_id, good_id)
)

which stores data about the products in each order. In Yii Described the relationship between orders and catalog:
public function relations()
  {
    return array(
      .....
      'orders'=>array(self::MANY_MANY, 'Orders', 'yii_order_items(good_id, order_id)'),
    );
  }

Question: If we have an active record for the Orders and catalog tables and we do not need to care how the data is stored in the database, how is the data written to the third table? I couldn't find an answer to this in the manuals. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-03-22
@webinar

Also active record. What's stopping you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question