3 つのモデル間の関係を作成しようとしています。私のモデルは、役割、責任、および従業員です。概念的には、次のように関係を設定すると思います。
従業員テーブル:
id:int Pk
fName: varChar
名前: varChar
ロール テーブル:
roldId: int pk
ロール名: varChar
責任表:
reponsibilityId: PK int
責任名: varChar
role_responsibility テーブル:
role_responsibility_id: PK int
roleId: int FK
責任 ID int FK
employee_role_responsibility テーブル:
id: int PK
role_responsibility_id int FK
employee_id: int FK
私の質問は、私の CakePHP モデルでこれらの関係をどのようにモデル化するのですか? これは私がこれまでに持っているものです:
App::uses('AppModel', 'Model');
class Employee extends AppModel {
public $name = "Employee";
}
App::uses('AppModel', 'Model');
class Role extends AppModel {
public $name = "Role";
public $hasAndBelongsToMany = array(
'MemberOf' => array(
'className' => 'Responsibility',
)
);
}
App::uses('AppModel', 'Model');
class Responsibility extends AppModel {
public $name = "Responsibility";
public $hasAndBelongsToMany = array(
'MemberOf' => array(
'className' => 'Role',
)
);
}
roles_responsbility テーブルを従業員テーブルと結合するにはどうすればよいですか?
ありがとう