改进belongstomany的查询字段指定

This commit is contained in:
thinkphp
2017-05-09 15:38:41 +08:00
parent 02f8e8a909
commit 513f1f32f7
2 changed files with 29 additions and 1 deletions

View File

@@ -376,7 +376,9 @@ class BelongsToMany extends Relation
// 关联查询封装
$tableName = $this->query->getTable();
$table = $this->pivot->getTable();
$query = $this->query->field($tableName . '.*')
$fields = $this->getQueryFields($tableName);
$query = $this->query->field($fields)
->field(true, false, $table, 'pivot', 'pivot__');
if (empty($this->baseQuery)) {