cakePHP: Filter selected list by variable
Posted
by
gonzela2006
on Stack Overflow
See other posts from Stack Overflow
or by gonzela2006
Published on 2012-11-02T16:58:27Z
Indexed on
2012/11/02
17:00 UTC
Read the original article
Hit count: 245
cakephp
|cakephp-2.0
I'm on cakePHP 2. I have a problem and I need your help. Here is some code of my controller(StudentsController.php) specifically "edit" function:
$students = $this -> Student -> find('list', array(
'order' => 'Student.name ASC'
));
$this -> set('students', $students);
How can I filter the list by the current student's class?? so the list will contain all students that has the same student's class
I need some code like this
$students = $this -> Student -> find('list', array(
'conditions' => array('Student.class_id' => CURRENT-STUDENT'S-CLASS),
'order' => 'Student.name ASC'
));
$this -> set('students', $students);
Please Advise
Thanks, gonzela2006
© Stack Overflow or respective owner