3つのモデルがあるとしましょう。
- 歯科医 (role='D' を持つユーザー)
- 応募者 (住所、電話番号、興味のある位置など、各ユーザーの詳細)
ポジション (表の申請者には、position_id のみを保存します。ここに説明があります)
class Dentist extends AppModel { public $hasOne = '申請者'; }
class Applicant extends AppModel { public $belongsTo = array('Dentists', 'Position'); }
class Position extends AppModel { }
DentistsController で使用すると、Dentists のビューに問題が$this->Dentist->find('all');
あります。
select *
from dentists left outer join applicants
on dentists.id = applicants.dentist_id
左外部結合位置のようなものはもうありません...
しかし$this->Applicant->find('all');
、ApplicantsController で使用すると、外部結合位置が残りました...
モデルの関連付けを設定して、DentistsController からテーブルの「位置」への結合ステートメントを取得する方法。
皆さんありがとう。