From 7deea9dd07b51c27d88179f2290303c8f6e454b3 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 20 May 2017 23:22:23 +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/Builder.php | 8 ++++---- library/think/db/Query.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 7a589d08..5665a939 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -88,7 +88,7 @@ abstract class Builder } // 获取绑定信息 - $bind = $this->query->getFieldsBind($options); + $bind = $this->query->getFieldsBind($options['table']); if ('*' == $options['field']) { $fields = array_keys($bind); } else { @@ -226,7 +226,7 @@ abstract class Builder // 附加软删除条件 list($field, $condition) = $options['soft_delete']; - $binds = $this->query->getFieldsBind($options); + $binds = $this->query->getFieldsBind($options['table']); $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; $whereStr = $whereStr . $this->parseWhereItem($field, $condition, '', $options, $binds); } @@ -251,7 +251,7 @@ abstract class Builder } $whereStr = ''; - $binds = $this->query->getFieldsBind($options); + $binds = $this->query->getFieldsBind($options['table']); foreach ($where as $key => $val) { $str = []; foreach ($val as $field => $value) { @@ -725,7 +725,7 @@ abstract class Builder { // 获取合法的字段 if ('*' == $options['field']) { - $fields = array_keys($this->query->getFieldsType($options)); + $fields = array_keys($this->query->getFieldsType($options['table'])); } else { $fields = $options['field']; } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index d9cc56a5..8140a229 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1776,21 +1776,21 @@ class Query } // 获取当前数据表字段信息 - public function getTableFields($options) + public function getTableFields($table = '') { - return $this->getTableInfo($options['table'], 'fields'); + return $this->getTableInfo($table ?: $this->getOptions('table'), 'fields'); } // 获取当前数据表字段类型 - public function getFieldsType($options) + public function getFieldsType($table = '') { - return $this->getTableInfo($options['table'], 'type'); + return $this->getTableInfo($table ?: $this->getOptions('table'), 'type'); } // 获取当前数据表绑定信息 - public function getFieldsBind($options) + public function getFieldsBind($table = '') { - $types = $this->getFieldsType($options); + $types = $this->getFieldsType($table); $bind = []; if ($types) { foreach ($types as $key => $type) {