From fdd41cd1c7076b569b05e8202b3074ed11f7e31b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 18 May 2016 11:01:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84getDat?= =?UTF-8?q?a=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 2 +- library/think/db/Query.php | 40 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index befb147e..9f0bd403 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -163,7 +163,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ public function getData($name = '') { - return isset($this->data[$name]) ? $this->data[$name] : $this->data; + return array_key_exists($name, $this->data) ? $this->data[$name] : $this->data; } /** diff --git a/library/think/db/Query.php b/library/think/db/Query.php index cb6a0f8c..c3a510c4 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -797,6 +797,26 @@ class Query return $this; } + /** + * 得到当前的数据表 + * @access public + * @param string $name + * @return string + */ + public function getTable($name = '') + { + if ($name || empty($this->table)) { + $name = $name ?: $this->name; + $tableName = $this->connection->getConfig('prefix'); + if ($name) { + $tableName .= Loader::parseName($name); + } + } else { + $tableName = $this->table; + } + return $tableName; + } + /** * 指定当前操作的数据表 * @access public @@ -1038,26 +1058,6 @@ class Query return $this; } - /** - * 得到当前的数据表 - * @access public - * @param string $name - * @return string - */ - public function getTable($name = '') - { - if ($name || empty($this->table)) { - $name = $name ?: $this->name; - $tableName = $this->connection->getConfig('prefix'); - if ($name) { - $tableName .= Loader::parseName($name); - } - } else { - $tableName = $this->table; - } - return $tableName; - } - /** * 获取数据表信息 * @access public