From 46353f20a0d37d0b5957ad76b9de0de634510f5e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 20 Feb 2017 17:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3JOIN=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=B8=80=E5=AF=B9=E4=B8=80=E5=85=B3=E8=81=94=E9=A2=84=E8=BD=BD?= =?UTF-8?q?=E5=85=A5=E9=97=AD=E5=8C=85=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/OneToOne.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/library/think/model/relation/OneToOne.php b/library/think/model/relation/OneToOne.php index 18b92225..c64dfcbb 100644 --- a/library/think/model/relation/OneToOne.php +++ b/library/think/model/relation/OneToOne.php @@ -67,6 +67,7 @@ abstract class OneToOne extends Relation $field = true; } $query->field($field, false, $table, $alias); + $field = null; } // 预载入封装 @@ -82,7 +83,7 @@ abstract class OneToOne extends Relation if ($closure) { // 执行闭包查询 - call_user_func_array($closure, [& $query]); + call_user_func_array($closure, [ & $query]); // 使用withField指定获取关联的字段,如 // $query->where(['id'=>1])->withField('id,name'); if ($query->getOptions('with_field')) { @@ -91,10 +92,8 @@ abstract class OneToOne extends Relation } } elseif (isset($this->option['field'])) { $field = $this->option['field']; - } else { - $field = true; } - $query->field($field, false, $joinTable, $joinAlias, $relation . '__'); + $query->field(isset($field) ? $field : true, false, $joinTable, $joinAlias, $relation . '__'); } /** @@ -290,7 +289,7 @@ abstract class OneToOne extends Relation { // 预载入关联查询 支持嵌套预载入 if ($closure) { - call_user_func_array($closure, [& $model]); + call_user_func_array($closure, [ & $model]); if ($field = $model->getOptions('with_field')) { $model->field($field)->removeOption('with_field'); }