From 372111c3a93b0bc65ef2314ab53a6db20bd87b5f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 2 Aug 2017 18:11:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 99f60315..d36bd468 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -335,6 +335,11 @@ abstract class Builder $bindName = md5($bindName); } + if (is_object($value) && method_exists($value, '__toString')) { + // 对象数据写入 + $value = $value->__toString(); + } + $bindType = isset($binds[$field]) ? $binds[$field] : PDO::PARAM_STR; if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) { if (strpos($value, ':') !== 0 || !$this->query->isBind(substr($value, 1))) {