改进模型的save方法 避免allowField方法影响而删除数据

This commit is contained in:
thinkphp
2017-06-27 08:17:53 +08:00
parent e40a795b43
commit a27f5299df

View File

@@ -975,9 +975,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
$pk = $this->getPk();
if ($this->isUpdate) {
// 检测字段
$this->checkAllowField($this->data, array_merge($this->auto, $this->update));
// 自动更新
$this->autoCompleteData($this->update);
@@ -988,6 +985,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 获取有更新的数据
$data = $this->getChangedData();
// 检测字段
$this->checkAllowField($data, array_merge($this->auto, $this->update));
if (empty($data) || (count($data) == 1 && is_string($pk) && isset($data[$pk]))) {
// 关联更新