From 6e94f2eae70aeddd7cd72976b79e7685ad421873 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 4 Jul 2017 09:08:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=B8=80=E5=A4=84=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=95=B0=E6=8D=AE=E5=BA=93=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=9A=B4=E9=9C=B2=E6=95=8F=E6=84=9F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 10 ++++++---- library/think/db/Query.php | 6 +++--- library/think/exception/DbException.php | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index b6e48cfd..5d57cebb 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -380,11 +380,13 @@ abstract class Builder if (array_key_exists($field, $binds)) { $bind = []; $array = []; - foreach ($value as $k => $v) { - if ($this->query->isBind($bindName . '_in_' . $k)) { - $bindKey = $bindName . '_in_' . uniqid() . '_' . $k; + $i = 0; + foreach ($value as $v) { + $i++; + if ($this->query->isBind($bindName . '_in_' . $i)) { + $bindKey = $bindName . '_in_' . uniqid() . '_' . $i; } else { - $bindKey = $bindName . '_in_' . $k; + $bindKey = $bindName . '_in_' . $i; } $bind[$bindKey] = [$v, $bindType]; $array[] = ':' . $bindKey; diff --git a/library/think/db/Query.php b/library/think/db/Query.php index a8722a1a..1ab48f46 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -2301,7 +2301,7 @@ class Query $key = is_string($cache['key']) ? $cache['key'] : md5(serialize($options) . serialize($this->bind)); $resultSet = Cache::get($key); } - if (!$resultSet) { + if (false === $resultSet) { // 生成查询SQL $sql = $this->builder->select($options); // 获取参数绑定 @@ -2323,7 +2323,7 @@ class Query } } - if (isset($cache) && $resultSet) { + if (isset($cache) && false !== $resultSet) { // 缓存数据集 $this->cacheData($key, $resultSet, $cache); } @@ -2481,7 +2481,7 @@ class Query $result = isset($resultSet[0]) ? $resultSet[0] : null; } - if (isset($cache) && $result) { + if (isset($cache) && false !== $result) { // 缓存数据 $this->cacheData($key, $result, $cache); } diff --git a/library/think/exception/DbException.php b/library/think/exception/DbException.php index 656d6913..532af5ef 100644 --- a/library/think/exception/DbException.php +++ b/library/think/exception/DbException.php @@ -36,6 +36,7 @@ class DbException extends Exception 'Error SQL' => $sql, ]); + unset($config['username'], $config['password']); $this->setData('Database Config', $config); }