From c676ff56cc11b6bd79711e36875c7ff68860d116 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 13 Sep 2016 15:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=9D=A1=E4=BB=B6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=9A=84=E5=8F=82=E6=95=B0=E7=BB=91=E5=AE=9A=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20=E5=8D=95=E4=B8=AA=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E5=A4=9A=E4=B8=AA=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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index efd1c28b..77175c82 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -260,7 +260,7 @@ abstract class Builder } // where子单元分析 - protected function parseWhereItem($field, $val, $rule = '', $options = [], $binds = []) + protected function parseWhereItem($field, $val, $rule = '', $options = [], $binds = [], $bindName = null) { // 字段分析 $key = $field ? $this->parseKey($field) : ''; @@ -280,8 +280,9 @@ abstract class Builder } else { array_push($val, $item); } - foreach ($val as $item) { - $str[] = $this->parseWhereItem($field, $item, $rule, $options, $binds); + foreach ($val as $k => $item) { + $bindName = 'where_' . $field . '_' . $k; + $str[] = $this->parseWhereItem($field, $item, $rule, $options, $binds, $bindName); } return '( ' . implode(' ' . $rule . ' ', $str) . ' )'; } @@ -298,8 +299,9 @@ 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) { if (strpos($value, ':') !== 0 || !$this->query->isBind(substr($value, 1))) { - $this->query->bind('where_' . $field, $value, $bindType); - $value = ':where_' . $field; + $bindName = $bindName ?: 'where_' . $field; + $this->query->bind($bindName, $value, $bindType); + $value = ':' . $bindName; } }