mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
修正JOIN方式一对一关联预载入闭包查询
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user