我在蛋糕PHP 2.我有问题,我需要你的帮助。这是我的控制器的一些代码(来自StudentsController.php),特别是“编辑”功能:
$students = $this -> Student -> find('list', array(
'order' => 'Student.name ASC'
));
$this -> set('students', $students);
如何按当前学生班级过滤列表,以便列表中包含所有具有相同学生班级的学生?
我需要一些像这样的代码
$students = $this -> Student -> find('list', array(
'conditions' => array('Student.class_id' => CURRENT-STUDENT'S-CLASS),
'order' => 'Student.name ASC'
));
$this -> set('students', $students);
答案 0 :(得分:0)
因此根据您的编辑功能,您的查找应该看起来像这样。
$students = $this -> Student -> find('list', array(
'conditions' => array('Student.class_id' => $this->request->data['Student']['class_id']),
'order' => 'Student.name ASC'
));