mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进一对一关联
This commit is contained in:
@@ -52,6 +52,7 @@ class BelongsTo extends OneToOne
|
|||||||
call_user_func_array($closure, [ & $this->query]);
|
call_user_func_array($closure, [ & $this->query]);
|
||||||
}
|
}
|
||||||
$relationModel = $this->query
|
$relationModel = $this->query
|
||||||
|
->removeWhereField($this->localKey)
|
||||||
->where($this->localKey, $this->parent->$foreignKey)
|
->where($this->localKey, $this->parent->$foreignKey)
|
||||||
->relation($subRelation)
|
->relation($subRelation)
|
||||||
->find();
|
->find();
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ class HasOne extends OneToOne
|
|||||||
call_user_func_array($closure, [ & $this->query]);
|
call_user_func_array($closure, [ & $this->query]);
|
||||||
}
|
}
|
||||||
// 判断关联类型执行查询
|
// 判断关联类型执行查询
|
||||||
$relationModel = $this->query->where($this->foreignKey, $this->parent->$localKey)->relation($subRelation)->find();
|
$relationModel = $this->query
|
||||||
|
->removeWhereField($this->foreignKey)
|
||||||
|
->where($this->foreignKey, $this->parent->$localKey)
|
||||||
|
->relation($subRelation)
|
||||||
|
->find();
|
||||||
|
|
||||||
if ($relationModel) {
|
if ($relationModel) {
|
||||||
$relationModel->setParent(clone $this->parent);
|
$relationModel->setParent(clone $this->parent);
|
||||||
|
|||||||
Reference in New Issue
Block a user