M
M
Michael2016-08-08 18:23:19
Yii
Michael, 2016-08-08 18:23:19

How to copy, edit and save an entry?

There is a record in which you need to change the data and save it, how can this be done?
Maybe there are better solutions. What about this?

$model = new SalesOrderAddress;
$result = $model->findOne(['rule' => 'rule']);

$model2 = new SalesOrderAddress;
$model2->load($result, '');
$model2->name = 111;
$model2->save();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Arutyunov, 2016-08-08
@springimport

Use the setAttributes() and getAttributes() methods.
The logic is the same as in the code you provided.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question