改进parseData方法的对象处理参数绑定

This commit is contained in:
thinkphp
2017-03-09 18:03:09 +08:00
parent b97c0a825e
commit 0fd6dbc80f

View File

@@ -98,15 +98,16 @@ abstract class Builder
$result = [];
foreach ($data as $key => $val) {
$item = $this->parseKey($key, $options);
if (is_object($val) && method_exists($val, '__toString')) {
// 对象数据写入
$val = $val->__toString();
}
if (false === strpos($key, '.') && !in_array($key, $fields, true)) {
if ($options['strict']) {
throw new Exception('fields not exists:[' . $key . ']');
}
} elseif (is_null($val)) {
$result[$item] = 'NULL';
} elseif (is_object($val) && method_exists($val, '__toString')) {
// 对象数据写入
$result[$item] = $val->__toString();
} elseif (isset($val[0]) && 'exp' == $val[0]) {
$result[$item] = $val[1];
} elseif (is_scalar($val)) {