mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进模型的save方法 避免allowField方法影响而删除数据
This commit is contained in:
@@ -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]))) {
|
||||
// 关联更新
|
||||
|
||||
Reference in New Issue
Block a user