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); }