From 0fd6dbc80f3af83dc381614a7fb408e133709cc1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 9 Mar 2017 18:03:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BparseData=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E5=AF=B9=E8=B1=A1=E5=A4=84=E7=90=86=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index b141a8b7..1fa2968a 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -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)) {