Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The join table : TestsRegistrations
- Tests table
- Registrations table
- People table
- // TestsRegistrations table
- $this->belongsTo('Tests'
- , [
- 'foreignKey' => 'test_id',
- 'joinType' => 'INNER'
- ]
- );
- $this->hasMany('Registrations', [
- 'foreignKey' => 'registration_id',
- 'joinType' => 'INNER'
- ]);
- ///Tests table
- $this->belongsToMany('Registrations', [
- 'className'=>'Registrations',
- 'foreignKey' => 'test_id',
- 'targetForeignKey' => 'registration_id',
- 'joinTable' => 'tests_registrations',
- //'through'=>'tests_registrations'
- ]);
- ///Registrations table
- $this->belongsToMany('Tests', [
- 'className'=>'Tests',
- 'foreignKey' => 'registration_id',
- 'targetForeignKey' => 'test_id',
- 'joinTable' => 'tests_registrations',
- //'through'=>'tests_registrations'
- ]);
- $this->belongsTo('People', [
- 'foreignKey' => 'person_id'
- ]);
- And the problem is that i need to acces Tests->TestsRegistration->People:
- What i try:
- $this->Tests=$this->Tests->find('all',['contain'=>['Registration']
- ])
- ->distinct('test_id')
- ->matching('Registrations')// ->matching('TestsRegistrations'):this does norks because its says TestsRegistrations does not associated with Tests
- ));
- Its possible to acces Tests->Registration but since people is associated to TestsRegistrations i stuck
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement