php - cant get data to group in find in a cakephp HABTM -


i have habtm relationship of students , subjects. want display subjects associated student without repetition of student details. dont want student details keep repeating in data output. how student details shown below output once , subjects associated student output?

group didnt work. didnt see answer in docs sure simple task do.

http://book.cakephp.org/2.0/en/models/retrieving-your-data.html

  $this->student->recursive = -1;            $joinoptions = array(       //  $options['joins'] = array(             array('table' => 'students_subjects',                 'alias' => 'studentssubject',                 'type' => 'left',                 'conditions' => array(                 'student.id = studentssubject.student_id',                  )                  ),              array('table' => 'subjects',                 'alias' => 'subject',                 'type' => 'left',                 'conditions' => array(                 'studentssubject.subject_id=subject.id',                  )                  ),                );              $fieldoptions =  array('student.id,student.last_name,student.first_name,student.address_street,student.address_suburb,'                                 . 'subject.name,subject.id, studentssubject.id, student.first_name,student.last_name,student.address_lat,student.address_long,student.tutor_gender_preference'                                );              $student=$this->student->find('all',array(                'conditions'=>   array( 'student.id' => $student_id),                 'fields'=>$fieldoptions,                 'joins'=> $joinoptions,               //  'group' => 'student.id',                 'recursive' =>-1,                 ));    array(     (int) 0 => array(         'student' => array(             'id' => '216',             'last_name' => 'ncc',             'first_name' => 'acc',             'address_street' => '8 sdsdt',             'address_suburb' => 'hasdsdk',             'address_lat' => 'xx',             'address_long' => 'xx',             'tutor_gender_preference' => 'no preference'         ),         'subject' => array(             'name' => 'english: year 7 - 10',             'id' => '9'         ),         'studentssubject' => array(             'id' => '531'         )     ),     (int) 1 => array(         'student' => array(             'id' => '216',             'last_name' => 'ncc',             'first_name' => 'acc',             'address_street' => '8 sdsdt',             'address_suburb' => 'hasdsdk',             'address_lat' => 'xx',             'address_long' => 'xx',             'tutor_gender_preference' => 'no preference'         ),         'subject' => array(             'name' => 'maths: year 7 - 10',             'id' => '16'         ),         'studentssubject' => array(             'id' => '532'         )     ),     (int) 2 => array(         'student' => array(             'id' => '216',             'last_name' => 'ncc',             'first_name' => 'acc',             'address_street' => '8 sdsdt',             'address_suburb' => 'hasdsdk',             'address_lat' => 'xx',             'address_long' => 'xx',             'tutor_gender_preference' => 'no preference'         ),         'subject' => array(             'name' => 'physics: year 11',             'id' => '28'         ),         'studentssubject' => array(             'id' => '583'         )     ) ) 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -