From e3a3acaed6e37e0cfeb0834c0bb5167a2181d68a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 13 Sep 2016 14:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=8F=82=E6=95=B0=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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 852b3a77..efd1c28b 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -296,10 +296,13 @@ abstract class Builder } } $bindType = isset($binds[$field]) ? $binds[$field] : PDO::PARAM_STR; - if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false && strpos($value, ':') !== 0) { - $this->query->bind('where_' . $field, $value, $bindType); - $value = ':where_' . $field; + if (is_scalar($value) && array_key_exists($field, $binds) && !in_array($exp, ['IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) { + if (strpos($value, ':') !== 0 || !$this->query->isBind(substr($value, 1))) { + $this->query->bind('where_' . $field, $value, $bindType); + $value = ':where_' . $field; + } } + $whereStr = ''; if (in_array($exp, ['=', '<>', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE'])) { // 比较运算 及 模糊匹配