From e54a81d720116ba4b3c956caf3c8403ff0389024 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 3 Jun 2016 18:12:47 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E7=9A=84data=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E6=9F=90=E4=B8=AA=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 2ef689fa..97e614e0 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -160,19 +160,21 @@ abstract class Model implements \JsonSerializable, \ArrayAccess {} /** - * 批量设置数据对象值 + * 设置数据对象值(不进行修改器处理) * @access public - * @param mixed $data 数据 + * @param mixed $data 数据或者属性名 + * @param mixed $value 值 * @return $this */ - public function data($data = '') + public function data($data, $value = null) { if (is_object($data)) { - $data = get_object_vars($data); - } elseif (!is_array($data)) { - throw new Exception('data type invalid', 10300); + $this->data = get_object_vars($data); + } elseif (is_array($data)) { + $this->data = $data; + } else { + $this->data[$data] = $value; } - $this->data = $data; return $this; }