mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
改进一对一查询
This commit is contained in:
@@ -220,4 +220,21 @@ class BelongsTo extends OneToOne
|
|||||||
|
|
||||||
return $this->parent->setRelation($this->relation, null);
|
return $this->parent->setRelation($this->relation, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行基础查询(仅执行一次)
|
||||||
|
* @access protected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function baseQuery()
|
||||||
|
{
|
||||||
|
if (empty($this->baseQuery)) {
|
||||||
|
if (isset($this->parent->{$this->foreignKey})) {
|
||||||
|
// 关联查询带入关联条件
|
||||||
|
$this->query->where($this->localKey, '=', $this->parent->{$this->foreignKey});
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->baseQuery = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,4 +190,20 @@ class HasOne extends OneToOne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行基础查询(仅执行一次)
|
||||||
|
* @access protected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function baseQuery()
|
||||||
|
{
|
||||||
|
if (empty($this->baseQuery)) {
|
||||||
|
if (isset($this->parent->{$this->localKey})) {
|
||||||
|
// 关联查询带入关联条件
|
||||||
|
$this->query->where($this->foreignKey, '=', $this->parent->{$this->localKey});
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->baseQuery = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user