From f3aceca2b06f8f1016955e213ba8bb14589cedd2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 21 May 2016 11:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84field?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 4 ++-- library/think/db/Query.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 8a10e2c8..933c3b5d 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -85,7 +85,7 @@ abstract class Builder if ('*' == $options['field']) { $fields = array_keys($bind); } else { - $fields = is_array($options['field']) ? $options['field'] : array_map('trim', explode(',', $options['field'])); + $fields = $options['field']; } $result = []; @@ -567,7 +567,7 @@ abstract class Builder if ('*' == $options['field']) { $fields = $this->query->getTableInfo($options['table'], 'fields'); } else { - $fields = is_array($options['field']) ? $options['field'] : array_map('trim', explode(',', $options['field'])); + $fields = $options['field']; } foreach ($dataSet as &$data) { diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 0d09d17b..8c3fe9bf 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -602,12 +602,12 @@ class Query return $this; } if (is_string($field)) { - $field = explode(',', $field); + $field = array_map('trim', explode(',', $field)); } if (true === $field) { // 获取全部字段 $fields = $this->getTableInfo($tableName, 'fields'); - $field = $fields ?: '*'; + $field = $fields ?: ['*']; } elseif ($except) { // 字段排除 $fields = $this->getTableInfo($tableName, 'fields');