think-orm
think-orm copied to clipboard
一对多withField无效
public function files()
{
return $this->belongsToMany(Fileinfo::class, RoomFile::class, 'fileid', 'serial');
}
$query->field('serial,roomname,starttime,endtime')
->with([
'files' => function (\think\model\Relation $query) {
$query->withField(['fileid','filename']);
}
])
依然还是查询了所有字段
SELECT
fileinfo.*,pivot.serialASpivot__serial,pivot.fileidASpivot__fileid,pivot.shownameASpivot__showname,pivot.typeASpivot__type,pivot.addtimeASpivot__addtime,pivot.suffixASpivot__suffix,pivot.sortASpivot__sort,pivot.warmvideoASpivot__warmvideoFROMfileinfoINNER JOINroomfilepivotONpivot.fileid=fileinfo.fileidWHERE (fileinfo.companyid= 1001219 ANDpivot.serial= '21431077062245' ) ANDfileinfo.deletetime= 0