我有一個表ComplexesEmployeesImmeubles:CakePHP的3鉛與將數據保存到BD
id auto-increment
complex_id foreign key of Complexes.ID
employee_id foreign key of Employees.ID
immeuble_id foreign key of Immeubles.ID
poste_id foreign key of Postes.ID
date_affectation
created
這裏是我的看法reaffecter.ctp
<?= $this->Form->create('ComplexesEmployeesImmeubles') ?>
<?php
echo $this->Form->select('complex_id', $complexes);
echo $this->Form->input('employee_id',['type' => 'hidden' , 'value' => h($employee->id)]);
echo $this->Form->select('immeuble_id', $immeubles);
echo $this->Form->select('poste_id', $postes);
echo $this->Form->input('salaire', ['label' => 'Salaire']);
echo $this->Form->input('date_affectation', ['label' => 'Date d\'affectation']);
?>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?>
在我的控制,我嘗試將數據保存到我的BD與下面的代碼,但沒有保存!
if ($this->request->is('post')) {
$complexesEmployeesImmeuble = $this->ComplexesEmployeesImmeubles->newEntity();
$complexesEmployeesImmeuble = $this->ComplexesEmployeesImmeubles->patchEntity($complexesEmployeesImmeuble, $this->request->data);
$this->ComplexesEmployeesImmeubles->save($complexesEmployeesImmeuble);}
「_Pb_」,「_BD_」?請不要使用這種粗略的縮寫,他們很難理解,甚至更難搜索。 – ndm