From dead0d561f8f8fac5dcb0c397395156f93d81e7c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 24 Aug 2016 17:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 3b33b4ae..54b8146b 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -44,9 +44,9 @@ class Query // 当前数据表主键 protected $pk; // 当前表字段类型信息 - protected $fieldType; + protected $fieldType = []; // 当前允许的字段列表 - protected $allowField; + protected $allowField = []; // 当前数据表前缀 protected $prefix = ''; // 查询参数 @@ -733,11 +733,11 @@ class Query } if (true === $field) { // 获取全部字段 - $fields = isset($this->allowField) ? $this->allowField : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields'); + $fields = !empty($this->allowField) && $this->getTable() == $tableName ? $this->allowField : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields'); $field = $fields ?: ['*']; } elseif ($except) { // 字段排除 - $fields = isset($this->allowField) ? $this->allowField : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields'); + $fields = !empty($this->allowField) && $this->getTable() == $tableName ? $this->allowField : $this->getTableInfo($tableName ?: (isset($this->options['table']) ? $this->options['table'] : ''), 'fields'); $field = $fields ? array_diff($fields, $field) : $field; } if ($tableName) {