改进追加关联模型属性的判断

This commit is contained in:
thinkphp
2016-12-14 15:08:07 +08:00
parent c0b8580738
commit 08c3be7c4c

View File

@@ -516,7 +516,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
if ($model instanceof Model) {
foreach ($append as $key => $attr) {
$key = is_numeric($key) ? $attr : $key;
$this->setAttr($key, $model->$attr);
if ($this->__isset($key)) {
throw new Exception('bind attr has exists:' . $key);
} else {
$this->setAttr($key, $model->$attr);
}
}
}
return $this;