mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
关联定义支持在关联方法中使用field获取指定查询字段
This commit is contained in:
@@ -1615,6 +1615,8 @@ class Query
|
|||||||
$field = $this->options['with_field'];
|
$field = $this->options['with_field'];
|
||||||
unset($this->options['with_field']);
|
unset($this->options['with_field']);
|
||||||
}
|
}
|
||||||
|
} elseif (isset($info['option']['field'])) {
|
||||||
|
$field = $info['option']['field'];
|
||||||
}
|
}
|
||||||
$this->field($field, false, $joinTable, $joinAlias, $relation . '__');
|
$this->field($field, false, $joinTable, $joinAlias, $relation . '__');
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ class Relation
|
|||||||
protected $query;
|
protected $query;
|
||||||
// 关联查询条件
|
// 关联查询条件
|
||||||
protected $where;
|
protected $where;
|
||||||
|
// 关联查询参数
|
||||||
|
protected $option;
|
||||||
/**
|
/**
|
||||||
* 架构函数
|
* 架构函数
|
||||||
* @access public
|
* @access public
|
||||||
@@ -74,6 +75,7 @@ class Relation
|
|||||||
'localKey' => $this->localKey,
|
'localKey' => $this->localKey,
|
||||||
'alias' => $this->alias,
|
'alias' => $this->alias,
|
||||||
'joinType' => $this->joinType,
|
'joinType' => $this->joinType,
|
||||||
|
'option' => $this->option,
|
||||||
];
|
];
|
||||||
return $name ? $info[$name] : $info;
|
return $name ? $info[$name] : $info;
|
||||||
}
|
}
|
||||||
@@ -689,8 +691,10 @@ class Relation
|
|||||||
}
|
}
|
||||||
$result = call_user_func_array([$this->query, $method], $args);
|
$result = call_user_func_array([$this->query, $method], $args);
|
||||||
if ($result instanceof \think\db\Query) {
|
if ($result instanceof \think\db\Query) {
|
||||||
|
$this->option = $result->getOptions();
|
||||||
return $this;
|
return $this;
|
||||||
} else {
|
} else {
|
||||||
|
$this->option = [];
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user