M
M
Mikha Pankratov2015-12-08 13:14:51
Yii
Mikha Pankratov, 2015-12-08 13:14:51

What array should be in $model->load()?

Hello everyone, I just can’t find it on Google - can someone quickly answer?
Why doesn't my array get passed in $model->load()?
This is the array I put in

[
    0 => [
        'id' => '2'
        'type' => '2'
        'date' => '12/01/2011'
    ]
]

The base is fine! The $model->load() does not accept.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Makarov, 2015-12-08
@frmax

The key is the name of the model class.

[
   'ИмяКласса' => [
        'id' => '2'
        'type' => '2'
        'date' => '12/01/2011'
    ]
]

Or without specifying it
$data = [
    'id' => '2'
    'type' => '2'
    'date' => '12/01/2011'
];

// второй параметр - пустая строка
$model->load($data, '');

Or you can use any of your keys, but you must also specify it explicitly.
$data = [
   'мой ключ' => [
        'id' => '2'
        'type' => '2'
        'date' => '12/01/2011'
    ]
];

$model->load($data, 'мой ключ');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question