改进Builder类的insertall方法 增加对null和对象数据的处理

This commit is contained in:
thinkphp
2016-12-27 13:43:31 +08:00
parent 7a26126a9b
commit d89fb4bd0a

View File

@@ -702,8 +702,13 @@ abstract class Builder
throw new Exception('fields not exists:[' . $key . ']');
}
unset($data[$key]);
} elseif (is_null($val)) {
$data[$key] = 'NULL';
} elseif (is_scalar($val)) {
$data[$key] = $this->parseValue($val, $key);
} elseif (is_object($val) && method_exists($val, '__toString')) {
// 对象数据写入
$data[$key] = $val->__toString();
} else {
// 过滤掉非标量数据
unset($data[$key]);