0
我有僱員和複雜的多對多關係。我使用了 烘焙控制檯爲Employees和Complexes表生成模型,控制器...。 我的問題是: - 因爲我有在我的BD表「complexes_employees」,我也必須烘烤型號 和控制器這個表也可以cakephP能夠知道它包含 僱員的兩個外鍵和配合。cakePHP 3以多對多關係保存數據
第二個問題: - 如何將數據保存在這三個表中。對於我的應用程序,我必須爲每個組合員工保存員工 。
// Employees Controller
public function addEmpPerComplex($id_complex){
$emp = $this->Employees->newEntity();
if ($this->request->is('post')) {
$employee = $this->Employees->patchEntity($employee, $this->request->data, ['associated'=>['Complexes._joinData']]);
//here I need to insert the record that contains the employee data in Employees Table
// then I need to insert in "complexes_employees" the ID of Complex sended in parametre of this function and the ID of the new Employee
謝謝你幫我
非常感謝,不,我不要在我的關聯中沒有其他字段「complexes_employees」,因此不需要爲此表創建模型和控制器。爲了保存代碼,我會嘗試你告訴我希望它能起作用。再次,謝謝你的時間和你的幫助:) – Hanane