无法从cakephp中的habtm获取所需记录

时间:2015-04-29 14:42:08

标签: cakephp

在Cakephp中,我需要让导师教授一门小学英语'。相反,我得到所有导师与任何主题,所以条件被忽略,没有错误。导师和他们教授的科目之间存在着一种关系。

 $this->Tutor->Behaviors->load('Containable'); 
        $tutors=$this->Tutor->find('all',array(
            'contain' => array('Subject',array( 'conditions'=> array('Subject.name' => 'Primary English'))),
          'contain' => array('Subject'),


        'recursive' =>-1,
               // 'order'=> $orderoptions,
           'fields'=>array('Tutor.last_name', 'Tutor.first_name','Tutor.id' ),

               )); 
          debug( $tutors);


array(
    (int) 0 => array(
        'Tutor' => array(
            'last_name' => 'Wyers',
            'first_name' => 'Adele',
            'id' => '13'
        ),
        'Subject' => array()
    ),
    (int) 1 => array(
        'Tutor' => array(
            'last_name' => 'Payet',
            'first_name' => 'Allison',
            'id' => '7'
        ),
        'Subject' => array(
            (int) 0 => array(
                'id' => '4',
                'name' => 'English - Year 11',
                'TutorsSubject' => array(
                    'id' => '30',
                    'tutor_id' => '7',
                    'subject_id' => '4'
                )
            ),

0 个答案:

没有答案