From b2a592f94d306c23a699931525b1aab092f69524 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 8 Apr 2016 14:42:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 8e225e10..f52fefeb 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -126,15 +126,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 转换为数组 * @access public - * @return Model + * @return array */ public function toArray() { - if (!empty($this->data)) { - return $this->data; - } else { - return []; - } + return !empty($this->data) ? $this->data : []; } /** @@ -179,12 +175,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // 标记字段更改 - if (!isset($this->data[$name]) || (isset($this->data[$name]) && $this->data[$name] != $value && !in_array($name, $this->change))) { + if (!isset($this->data[$name]) || ($this->data[$name] != $value && !in_array($name, $this->change))) { $this->change[] = $name; } // 设置数据对象属性 $this->data[$name] = $value; - } /**