我有这样的查询:
$q = $q
//->select($this->LessonPupils) // Does not work
->select([
'OutLessonPupils.*', // Does not work
'Groups.id',
])
->where($conditions)
->order($order)
->contain([
'Pupils',
'Pupils.Groups',
'Pupils.OutLessonPupils'
]);
我想从Pupils
关联OutLessonPupils
中选择使用LessonPupils
表格类的所有字段,但我似乎无法使其工作,我在文档中找不到任何内容关于这个。
如何从OutLessonPupils
中选择所有字段?
答案 0 :(得分:2)
需要通过调用协会->select($this->Pupils->OutLessonPupils)
来选择您的代码
$q = $q->select($this->Pupils->OutLessonPupils)
->select([
'Groups.id',
])
->where($conditions)
->order($order)
->contain([
'Pupils',
'Pupils.Groups',
'Pupils.OutLessonPupils'
]);