改进模型数据验证

This commit is contained in:
thinkphp
2018-12-11 12:11:29 +08:00
parent d1a887cad7
commit e0c8c71190
4 changed files with 15 additions and 16 deletions

View File

@@ -1043,15 +1043,17 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
// 数据自动验证
if (!$this->validateData($data)) {
return false;
if (!empty($data)) {
if (!$this->validateData($data)) {
return false;
}
// 数据对象赋值
foreach ($data as $key => $value) {
$this->setAttr($key, $value, $data);
}
}
// 数据对象赋值
foreach ($data as $key => $value) {
$this->setAttr($key, $value, $data);
}
if (!empty($where)) {
$this->isUpdate = true;
$this->updateWhere = $where;