M
M
Mikha Pankratov2015-12-10 12:42:56
Yii
Mikha Pankratov, 2015-12-10 12:42:56

How to save, update a model with a multidimensional array?

Good afternoon,
until I understand how to save my model where is a multidimensional array.
Here comes to me such an array.

[
    0 => [
        1 => [
            0 => app\models\User#1
            (
                [yii\db\BaseActiveRecord:_attributes] => [
                    'id' => '148'
                    'created' => '2015-04-21 10:42:27'
                    'modified' => '2015-05-21 08:28:25'
                    'number' => '2347777awsdas12345'
                    'is_active' => 0
                ]
                [yii\db\BaseActiveRecord:_oldAttributes] => [
                    'id' => '148'
                    'created' => '2015-04-21 10:42:27'
                    'modified' => '2015-05-21 08:28:25'
                    'number' => '7777awsdas12345'
                    'is_active' => 1
                ]
                [yii\db\BaseActiveRecord:_related] => []
                [yii\base\Model:_errors] => null
                [yii\base\Model:_validators] => null
                [yii\base\Model:_scenario] => 'default'
                [yii\base\Component:_events] => []
                [yii\base\Component:_behaviors] => []
            )
        ]
        2 => [
            1 => app\models\User#2
            (
                [yii\db\BaseActiveRecord:_attributes] => [
                    'id' => '149'
                    'created' => '2015-11-30 03:24:39'
                    'modified' => '2015-11-30 03:24:39'
                    'number' => 'sadsad1231231233'
                    'is_active' => 0
                ]
                [yii\db\BaseActiveRecord:_oldAttributes] => [
                    'id' => '149'
                    'created' => '2015-11-30 03:24:39'
                    'modified' => '2015-11-30 03:24:39'
                    'number' => '1231231233'
                    'is_active' => 1
                ]
                [yii\db\BaseActiveRecord:_related] => []
                [yii\base\Model:_errors] => null
                [yii\base\Model:_validators] => null
                [yii\base\Model:_scenario] => 'default'
                [yii\base\Component:_events] => []
                [yii\base\Component:_behaviors] => []
            )
        ]
    ]
]

What should I do with it how to do my usual save()?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cyril, 2015-12-10
@frmax

Loop through this array and call the save() method for each model;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question