This commit is contained in:
thinkphp
2016-12-14 14:23:20 +08:00
parent 78e5980451
commit 5ba052d94f

View File

@@ -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);
}
}
}