Changeset 4499

Show
Ignore:
Timestamp:
06/08/08 21:16:37 (13 months ago)
Author:
guilhermeblanco
Message:

Fixes #1113. You have another problem with your model. M:N relations should never map both sides with hasOne and also they should be mapped in both directions to work correctly.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/tests/Ticket/1113TestCase.php

    r4498 r4499  
    8686    public function setUp() 
    8787    { 
    88         $this->hasMany('VIH_Model_Course_SubjectGroup as SubjectGroups', array('refClass' => 'VIH_Model_Course_SubjectGroup_Subject', 
    89                                                                                'local'    => 'subject_id', 
    90                                                                                    'foreign'  => 'subject_group_id')); 
     88        $this->hasMany( 
     89            'VIH_Model_Course_SubjectGroup as SubjectGroups',  
     90            array( 
     91                'refClass' => 'VIH_Model_Course_SubjectGroup_Subject', 
     92                'local'    => 'subject_id', 
     93                'foreign'  => 'subject_group_id' 
     94            ) 
     95        ); 
     96 
     97        $this->hasMany( 
     98            'VIH_Model_Course_Registration as Registrations', 
     99            array( 
     100                'refClass' => 'VIH_Model_Course_Registration_Subject', 
     101                'local'    => 'subject_id', 
     102                'foreign'  => 'registration_id' 
     103            ) 
     104        ); 
    91105    } 
    92106} 
     
    187201        $this->hasColumn('subject_id', 'integer', null, array('primary' => true)); 
    188202    } 
    189  
    190     public function setUp() 
    191     { 
    192         $this->hasOne('VIH_Model_Course_Registration as Registration', array('local'   => 'registration_id', 
    193                                                                              'foreign' => 'id')); 
    194  
    195         $this->hasOne('VIH_Model_Subject as Subject', array('local'   => 'subject_id', 
    196                                                             'foreign' => 'id')); 
    197     } 
    198 } 
     203}