From 3935ed59157570965b5fe5e4308f52f9db0ca5b6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 9 Nov 2016 16:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E8=81=94=E5=AE=9A=E4=B9=89=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=9C=A8=E5=85=B3=E8=81=94=E6=96=B9=E6=B3=95=E4=B8=AD?= =?UTF-8?q?=E4=BD=BF=E7=94=A8field=E8=8E=B7=E5=8F=96=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 2 ++ library/think/model/Relation.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 4636377b..99ae42a4 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1615,6 +1615,8 @@ class Query $field = $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 . '__'); $i++; diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index 22670bdd..f9675c14 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -47,7 +47,8 @@ class Relation protected $query; // 关联查询条件 protected $where; - + // 关联查询参数 + protected $option; /** * 架构函数 * @access public @@ -74,6 +75,7 @@ class Relation 'localKey' => $this->localKey, 'alias' => $this->alias, 'joinType' => $this->joinType, + 'option' => $this->option, ]; return $name ? $info[$name] : $info; } @@ -689,8 +691,10 @@ class Relation } $result = call_user_func_array([$this->query, $method], $args); if ($result instanceof \think\db\Query) { + $this->option = $result->getOptions(); return $this; } else { + $this->option = []; return $result; } } else {