From b7f38230b1b5919ac7c57d90c505461d76952d28 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 10 Sep 2016 22:27:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Builder=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 0aa9fc1d..11f372da 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -89,24 +89,22 @@ abstract class Builder $result = []; foreach ($data as $key => $val) { + $item = $this->parseKey($key); if (!in_array($key, $fields, true)) { if ($options['strict']) { throw new Exception('fields not exists:[' . $key . ']'); } - } else { - $item = $this->parseKey($key); - if (isset($val[0]) && 'exp' == $val[0]) { - $result[$item] = $val[1]; - } elseif (is_null($val)) { - $result[$item] = 'NULL'; - } elseif (is_scalar($val)) { - // 过滤非标量数据 - if ($this->query->isBind(substr($val, 1))) { - $result[$item] = $val; - } else { - $this->query->bind($key, $val, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR); - $result[$item] = ':' . $key; - } + } else if (isset($val[0]) && 'exp' == $val[0]) { + $result[$item] = $val[1]; + } elseif (is_null($val)) { + $result[$item] = 'NULL'; + } elseif (is_scalar($val)) { + // 过滤非标量数据 + if ($this->query->isBind(substr($val, 1))) { + $result[$item] = $val; + } else { + $this->query->bind($key, $val, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR); + $result[$item] = ':' . $key; } } }