From b8e5437f1c6c47733d3a840b1c94695483b411a5 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 6 May 2016 16:23:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Relation=E7=B1=BBsave=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5=E6=A8=A1=E5=9E=8B=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/Relation.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index fd29647b..1dac652f 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -453,6 +453,9 @@ class Relation */ public function save($data, array $pivot = []) { + if ($data instanceof Model) { + $data = $data->toArray(); + } // 判断关联类型 switch ($this->type) { case self::HAS_ONE: From 2a42932f1242327c383494d684dff4b15a6e7858 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 6 May 2016 16:23:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Relation=E7=B1=BB=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/Relation.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index 1dac652f..f1eecad4 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -14,6 +14,7 @@ namespace think\model; use think\Db; use think\Exception; use think\Loader; +use think\Model; use think\model\Pivot; class Relation