修正Model 修改器方法执行多次的问题

This commit is contained in:
thinkphp
2016-04-08 14:37:48 +08:00
parent 303a8c7169
commit f3a0c1f77e

View File

@@ -179,7 +179,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
// 标记字段更改
if (isset($this->data[$name]) && $this->data[$name] != $value && !in_array($name, $this->change)) {
if (!isset($this->data[$name]) || (isset($this->data[$name]) && $this->data[$name] != $value && !in_array($name, $this->change))) {
$this->change[] = $name;
}
// 设置数据对象属性
@@ -360,8 +360,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
// 写入回调
$this->trigger('after_write', $this);
// 清空
$this->isUpdate = null;
// 标记为更新
$this->isUpdate = true;
return $result;
}