mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
修正Relation类的一对多关联预载入查询
This commit is contained in:
@@ -93,7 +93,7 @@ class Relation
|
|||||||
$result = $relation->where($localKey, $this->parent->$foreignKey)->find();
|
$result = $relation->where($localKey, $this->parent->$foreignKey)->find();
|
||||||
break;
|
break;
|
||||||
case self::HAS_MANY:
|
case self::HAS_MANY:
|
||||||
$result = $relation->select();
|
$result = $relation->where($foreignKey, $this->parent->$localKey)->select();
|
||||||
break;
|
break;
|
||||||
case self::HAS_MANY_THROUGH:
|
case self::HAS_MANY_THROUGH:
|
||||||
$result = $relation->select();
|
$result = $relation->select();
|
||||||
@@ -659,12 +659,6 @@ class Relation
|
|||||||
{
|
{
|
||||||
if ($this->query) {
|
if ($this->query) {
|
||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case self::HAS_MANY:
|
|
||||||
if (isset($this->parent->{$this->localKey})) {
|
|
||||||
// 关联查询带入关联条件
|
|
||||||
$this->query->where($this->foreignKey, $this->parent->{$this->localKey});
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case self::HAS_MANY_THROUGH:
|
case self::HAS_MANY_THROUGH:
|
||||||
$through = $this->middle;
|
$through = $this->middle;
|
||||||
$model = $this->model;
|
$model = $this->model;
|
||||||
|
|||||||
Reference in New Issue
Block a user