From 99edfd8c68036cb4ff8959400207c906b15d273e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=96=B7=E5=9A=8F=E6=98=AF=E6=80=9D?= =?UTF-8?q?=E5=BF=B5?= <1035936946@qq.com> Date: Fri, 12 Jan 2024 02:16:25 +0000 Subject: [PATCH] =?UTF-8?q?update=20src/model/relation/OneToOne.php.=20mat?= =?UTF-8?q?ch=20=E6=96=B9=E6=B3=95=E4=B8=AD=E6=B7=BB=E5=8A=A0=20hidden=20e?= =?UTF-8?q?agerly=20=E6=96=B9=E6=B3=95=E4=B8=AD=E6=B7=BB=E5=8A=A0=20$field?= =?UTF-8?q?=20=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在withJoin下 bind 方法,运行查询和现实不一致问题 Signed-off-by: 一个喷嚏是思念 <1035936946@qq.com> --- src/model/relation/OneToOne.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/model/relation/OneToOne.php b/src/model/relation/OneToOne.php index 035e579..04a1e69 100644 --- a/src/model/relation/OneToOne.php +++ b/src/model/relation/OneToOne.php @@ -119,7 +119,9 @@ abstract class OneToOne extends Relation $field = $this->withField; } } - + if ($field === true) { + $field = $this->bindAttr ?: true; + } $query->join([$joinTable => $joinAlias], $joinOn, $joinType) ->tableField($field, $joinTable, $joinAlias, $relation . '__'); } @@ -280,6 +282,7 @@ abstract class OneToOne extends Relation if (!empty($this->bindAttr)) { $this->bindAttr($result, $relationModel); + $result->hidden([$relation], true); } } else { $relationModel = null; -- Gitee