From b0237b766db590d0d834868bd08a9ba8b4a212a6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 28 Dec 2016 11:37:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=85=B3=E8=81=94=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E4=B8=AD=E5=8C=85=E5=90=AB=E6=9F=A5=E8=AF=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E5=90=8E=E9=87=8D=E5=A4=8D=E6=89=A7=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 8 +++++--- library/think/model/Relation.php | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 7bc75c3d..c4fd0dc1 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1005,9 +1005,11 @@ class Query * @param string $option 参数名 * @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]); } return $this; @@ -1658,7 +1660,7 @@ class Query /** @var Relation $model */ $relation = Loader::parseName($relation, 1, false); - $model = $class->$relation(); + $model = $class->$relation()->removeOption(); if ($model instanceof OneToOne && 0 == $model->getEagerlyType()) { $model->eagerly($this, $relation, $subRelation, $closure, $first); $first = false; diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index 4fc68ff2..9766ce2e 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -92,6 +92,17 @@ abstract class Relation return $this; } + /** + * 移除关联查询参数 + * @access public + * @return $this + */ + public function removeOption() + { + $this->query->removeOption(); + return $this; + } + public function __call($method, $args) { if ($this->query) {