mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-03 05:52:48 +08:00
增加db_fields_strict配置参数,用于设置当字段不存在的数据写入的时候是否抛出异常 ,默认为true
This commit is contained in:
@@ -195,6 +195,9 @@ class Model
|
||||
if (!empty($fields)) {
|
||||
foreach ($data as $key => $val) {
|
||||
if (!in_array($key, $fields, true)) {
|
||||
if (Config::get('db_fields_strict')) {
|
||||
throw new Exception(' fields not exists :[' . $key . '=>' . $val . ']');
|
||||
}
|
||||
unset($data[$key]);
|
||||
} elseif (is_scalar($val) && empty($this->options['bind'][':' . $key])) {
|
||||
// 字段类型检查
|
||||
|
||||
Reference in New Issue
Block a user