Answer the question
In order to leave comments, you need to log in
How to work with Model::loadMultiple without a form?
Good afternoon.
Can you please tell me how to use loadMultiple without a form?
There is a console controller that serves to process files, and, accordingly, write to the database:
public function actionLoad()
{
//...
foreach ($this->files as $file) {
$clients[] = new ClientModel();
$list = self::parseXMLFile($file);
if (Model::loadMultiple($clients, $list, '')){
print_r($clients);
} else {
print_r($clients);
}
// ...
}
// ...
}
$client = new ClientModel();
$client->load($list[1], '');
Answer the question
In order to leave comments, you need to log in
Check that you $list
must have an array with the key ClientModel, like:
[
'ClientModel'=>['someAttribute'=>'somedata'],
'SecondModel'=>['someAttribute'=>'somedata']
]
$list = ['ClientModel'=>self::parseXMLFile($file)];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question