A
A
andruxin2014-03-11 12:08:18
Yii
andruxin, 2014-03-11 12:08:18

Yii. Is it possible to see in beforeSave which fields of the model will be updated?

Is it possible to see in beforeSave which fields of the model will be updated? And How?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri Morozov, 2014-03-11
@andruxin

All fields will be updated.
If you want to know which fields have been changed, save the original values ​​in afterFind and compare with the new ones in beforeSave.
The ability to update only dirty fields appeared only in the second version.

S
Sergey, 2014-03-11
Protko @Fesor

1. in beforeSave get the object from the database and diff the _attributes property.
2. overload the magic set method, and remember what has changed, writing somewhere the field, the changed and the old value.

T
TekVanDo, 2014-03-11
@TekVanDo

Well, at least you can select the current object from the database in beforeSave and compare its fields with the new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question