A
A
Alexey2015-11-03 09:39:51
1C
Alexey, 2015-11-03 09:39:51

How to save multidimensional array?

How to save an array of this kind?

[6] => Array
        (
            [ID] => 15
            [ORDER_ID] => 6
            [DATE_INSERT] => 2015-10-29 11:40:31
            [products] => Array
                (
                    [0] => Array
                        (
                            [ORDER_ID] => 6
                            [NAME] => Нижнее белье Белая Свобода
                            [QUANTITY] => 1.0000
                            [PRICE] => 1259.1000
                        )

                    [1] => Array
                        (
                            [ORDER_ID] => 6
                            [NAME] => Платье Весенняя Легкость
                            [QUANTITY] => 1.0000
                            [PRICE] => 2999.0000
                        )

                )

        )

I accept a request in the form of json. I parse using regular means 1c (Reading JSON). The output is a result of type "Match". How to save all this? Tried to struct, but the struct only saves the last order. For with each iteration it rewrites the data. I tried an array of structures, but it did not work because there can be 10 and 20 products in one order. In the array, it will just be porridge. Any suggestions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Lyzlov, 2015-11-03
@alexeyshi

Can't save an array of links to products?
That is something like this:

{
id: 15,
order_id: 6,
products: [id1, id2, ..., idN]
}

and store products in a separate database with their IDs. That will be the best thing to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question