From 5ba052d94fb749cfc60373441ba553e5f7711c9f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 14 Dec 2016 14:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/OneToOne.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/think/model/relation/OneToOne.php b/library/think/model/relation/OneToOne.php index fb36591f..0165314f 100644 --- a/library/think/model/relation/OneToOne.php +++ b/library/think/model/relation/OneToOne.php @@ -219,10 +219,11 @@ abstract class OneToOne extends Relation protected function bindAttr($model, &$result, $bindAttr) { foreach ($bindAttr as $key => $attr) { - if (!isset($result->$attr)) { - $result->setAttr(is_numeric($key) ? $attr : $key, $model->$attr); + $key = is_numeric($key) ? $attr : $key; + if (isset($result->$key)) { + throw new Exception('bind attr has exists:' . $key); } else { - throw new Exception('bind attr has exists:' . $attr); + $result->setAttr($key, $model->$attr); } } }