From 942aa65c2d289fca005111f085d03210ca1b3be7 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 13 Sep 2016 15:20:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BRelation=E7=B1=BB=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0getModel=E5=92=8CgetParentModel=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/Relation.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index 48d7851f..bfaeb0d3 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -126,6 +126,26 @@ class Relation return $result; } + /** + * 获取父模型对象 + * @access public + * @return Model + */ + public function getParentModel() + { + return $this->parent; + } + + /** + * 获取当前的模型对象 + * @access public + * @return Model + */ + public function getModel() + { + return (new $this->model); + } + /** * 预载入关联查询 返回数据集 * @access public