我将对此使用什么查询
|
我有一张
Relationship
桌子,可链接老师和学生
Teacher Student
1 1
1 2
2 1
2 3
Students
表格将包含有关学生的特定数据
Id Date of birth First Name
1 1990-10-10 Bill Smith
2 1989-01-03 Adam Smithson
我想选择所有属于老师1的学生。现在,我这样做(这是ORM语法的推动力)。
$relationships = RelationshipQuery::create()->filterByTeacher($teacherid)->find();
foreach($relationships as $relationship){
$studentId = $relationship->getStudent();
//use the studentId to get the actual student object
$student = StudentQuery::create()->findPk($studentId);
//after I get the student, I add it to an array
$students[] = $student;
}
问题在于,我最终得到的是数组,而不是正常的“ 5”时得到的通常的propelCollection。有没有一种方法可以稍微清理此查询(使用联接之类的方法),以便从一开始就以PropelCollection结尾?
没有找到相关结果
已邀请:
1 个回复
亥套惟间连