In the model constructor, the $origin is initialized in the following way
if (Is_object ($data)) { $this->data = Get_object_vars ($data);} else { $this->data = $data;} Record raw Data $this->origin = $this->data;
$origin save an array, because if you save an object, because the object is a reference, the modification will change the $data and $origin at the same time.
The effect we need is to $origin the original data at the time of the initial initialization.
In Thinkphp's save function, you can compare $data and $origin to find out which fields have been modified so that you can update only the modified fields when you update them.
$data = Array_udiff_assoc ($this->data, $this->origin, function ($a, $b) { if (empty ($a) | | empty ($b)) &&am P $a!== $b) { return 1; } return Is_object ($a) | | $a! = $b? 1:0;});
The role of model object $origin object in thinkphp frame