这里有问题。所以我有两个表,“ Groups”和“ User”,以及一个“ through”表“ GroupsMembers”,我需要做的是限制我得到的列。主要是因为我不需要它们,并且用户具有关联的另一个表(等级),该表也具有与我无关的列。
我可以使用查找器限制用户的列,但不能限制“通过”表(GroupsMembers和Grades)的列。有任何想法吗?有可能吗?
//GroupsController code
$mdlGroup = $this->MdlGroups->get($id, [
'contain' => ['MdlCourse', 'MdlUser' => ['finder' => 'limitRows'], 'MdlUser.MdlGradeItems'],
'finder' => 'limitRows',
]);
//GroupsTable code
$this->belongsToMany('MdlUser', [
'joinTable' => 'MdlUser',
'through' => 'MdlGroupsMembers',
'foreignKey' => 'groupid',
'targetForeignKey' => 'userid',
]);
//GroupsMembers code
$this->belongsTo('MdlUser', [
'foreignKey' => 'userid',
'joinType' => 'INNER',
]);
$this->belongsTo('MdlGroups', [
'foreignKey' => 'groupid',
'joinType' => 'INNER'
]);
//UserTable code
$this->belongsToMany('MdlGroups', [
'joinTable' => 'MdlGroups',
'through' => 'MdlGroupsMembers',
'foreignKey' => 'userid',
'targetForeignKey' => 'groupid',
]);
$this->belongsToMany('MdlGradeItems', [
'joinTable' => 'MdlGradeItems',
'through' => 'MdlGradeGrades',
'foreignKey' => 'userid',
'targetForeignKey' => 'itemid',
]);