diff --git a/library/think/Model.php b/library/think/Model.php index f1c91582..47f90d47 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -631,9 +631,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 检测字段 if (!empty($this->field)) { - $this->db(); foreach ($this->data as $key => $val) { - if (!in_array($key, $this->field)) { + if (!in_array($key, $this->field) && !array_key_exists($key, $this->field)) { unset($this->data[$key]); } }