改进model类save方法对字段的判断

This commit is contained in:
thinkphp
2016-09-17 11:27:35 +08:00
parent 9032818794
commit e562cb4080

View File

@@ -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]);
}
}