mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
改进关联定义中包含查询条件后重复执行的问题
This commit is contained in:
@@ -1005,9 +1005,11 @@ class Query
|
|||||||
* @param string $option 参数名
|
* @param string $option 参数名
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function removeOption($option)
|
public function removeOption($option = '')
|
||||||
{
|
{
|
||||||
if (isset($this->options[$option])) {
|
if ('' === $option) {
|
||||||
|
$this->options = [];
|
||||||
|
} elseif (isset($this->options[$option])) {
|
||||||
unset($this->options[$option]);
|
unset($this->options[$option]);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1658,7 +1660,7 @@ class Query
|
|||||||
|
|
||||||
/** @var Relation $model */
|
/** @var Relation $model */
|
||||||
$relation = Loader::parseName($relation, 1, false);
|
$relation = Loader::parseName($relation, 1, false);
|
||||||
$model = $class->$relation();
|
$model = $class->$relation()->removeOption();
|
||||||
if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) {
|
if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) {
|
||||||
$model->eagerly($this, $relation, $subRelation, $closure, $first);
|
$model->eagerly($this, $relation, $subRelation, $closure, $first);
|
||||||
$first = false;
|
$first = false;
|
||||||
|
|||||||
@@ -92,6 +92,17 @@ abstract class Relation
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除关联查询参数
|
||||||
|
* @access public
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function removeOption()
|
||||||
|
{
|
||||||
|
$this->query->removeOption();
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function __call($method, $args)
|
public function __call($method, $args)
|
||||||
{
|
{
|
||||||
if ($this->query) {
|
if ($this->query) {
|
||||||
|
|||||||
Reference in New Issue
Block a user