Sunday, August 31, 2014

Re: find all on complex model

Hi Stephen,
Yes your example was a great effort and I solved the problem. The issue is that I didnt add the fields argument in so this kept giving me undefined errors.
I dont think your code will work as you dont specify fields.
Your models are setup like mine s that was really well done.

Also I need a find all as find first returns only 1 row.



      $this->Lesson->recursive = -1;
    
            $options['joins'] = array(
               array('table' => 'lessons_students',
                'alias' => 'LessonsStudent',
                'type' => 'LEFT',
                'conditions' => array(
                'Lesson.id = LessonsStudent.lesson_id',
                 )
                 ),
               
                array('table' => 'students',
                'alias' => 'Student',
                'type' => 'LEFT',
                'conditions' => array(
                'LessonsStudent.student_id=Student.id',
                 )
                 ),
                       
            );
           
   
        
       
    
      $options['fields'] = array('Student.*','Lesson.*','LessonsStudent.*');
       
             $options['conditions'] = array('Lesson.tutor_id'  => 2);
           
           
   $student=$this->set( 'student',$this->Lesson->find('all', $options));

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: