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

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

View File

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