mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进模型的save方法 避免allowField方法影响而删除数据
This commit is contained in:
@@ -975,9 +975,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
$pk = $this->getPk();
|
$pk = $this->getPk();
|
||||||
if ($this->isUpdate) {
|
if ($this->isUpdate) {
|
||||||
// 检测字段
|
|
||||||
$this->checkAllowField($this->data, array_merge($this->auto, $this->update));
|
|
||||||
|
|
||||||
// 自动更新
|
// 自动更新
|
||||||
$this->autoCompleteData($this->update);
|
$this->autoCompleteData($this->update);
|
||||||
|
|
||||||
@@ -988,6 +985,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
|
|
||||||
// 获取有更新的数据
|
// 获取有更新的数据
|
||||||
$data = $this->getChangedData();
|
$data = $this->getChangedData();
|
||||||
|
// 检测字段
|
||||||
|
$this->checkAllowField($data, array_merge($this->auto, $this->update));
|
||||||
|
|
||||||
if (empty($data) || (count($data) == 1 && is_string($pk) && isset($data[$pk]))) {
|
if (empty($data) || (count($data) == 1 && is_string($pk) && isset($data[$pk]))) {
|
||||||
// 关联更新
|
// 关联更新
|
||||||
|
|||||||
Reference in New Issue
Block a user