改进Model类setAttr方法

This commit is contained in:
thinkphp
2016-12-07 15:33:15 +08:00
parent 73c47acef8
commit 90b0da7bed

View File

@@ -292,7 +292,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
// 标记字段更改
if (!isset($this->data[$name]) || (0 !== strcmp($this->data[$name], $value) && !in_array($name, $this->change))) {
if (isset($this->data[$name]) && is_scalar($this->data[$name]) && is_scalar($value) && 0 !== strcmp($this->data[$name], $value)) {
$this->change[] = $name;
} elseif (!isset($this->data[$name]) || $value != $this->data[$name]) {
$this->change[] = $name;
}
// 设置数据对象属性