From b97c0a825e1e27b8602f0bc0579b5565fb6ed6ac Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 9 Mar 2017 17:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BBuilder=E7=B1=BB=E7=9A=84pars?= =?UTF-8?q?eData=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 5097016d..b141a8b7 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -102,10 +102,13 @@ abstract class Builder if ($options['strict']) { throw new Exception('fields not exists:[' . $key . ']'); } - } elseif (isset($val[0]) && 'exp' == $val[0]) { - $result[$item] = $val[1]; } 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)) { // 过滤非标量数据 if (0 === strpos($val, ':') && $this->query->isBind(substr($val, 1))) { @@ -115,9 +118,6 @@ abstract class Builder $this->query->bind('__data__' . $key, $val, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR); $result[$item] = ':__data__' . $key; } - } elseif (is_object($val) && method_exists($val, '__toString')) { - // 对象数据写入 - $result[$item] = $val->__toString(); } } return $result;