1
我試圖將數據保存在多個模型關聯中,但同樣沒有保存。我已經正確設置了所有數據,即表單數據正常(調試顯示所有數據),並且查找也獲取數據,但無法理解問題所在。我的代碼如下爲:Cakephp數據不會保存在多個模型關聯中
控制器:
if($url == "expense_reports") { $this->set('tab_content','Invoice - Expense Reports'); $this->render('/job/invoice2');
if($this->request->is('post'))
{//debug($this->data);
$this->Event->Invoice->Expense->save($this->data); }
}
模型(協會):
事件
public $belongsTo = array(
'EventType' => array(
'className' => 'AgencyCalendar.EventType',
'foreignKey' => 'event_type_id'
)
);
public $hasMany = array(
'Invoice' => array(
'className' => 'AgencyCalendar.Invoice',
'foreignKey' => 'event_id',
'dependent' => false
)
);
發票
public $belongsTo = array(
'Event' => array(
'className' => 'AgencyCalendar.Event',
'foreignKey' => 'event_id'
)
);
public $hasMany = array(
'Expense' => array(
'className' => 'AgencyCalendar.Expense',
'foreignKey' => 'invoice_id',
'dependent' => false
)
);
費用
public $belongsTo = array(
'Invoice' => array(
'className' => 'AgencyCalendar.Invoice',
'foreignKey' => 'invoice_id'
)
);
我也沒有得到任何SQL轉儲在我看來,這個特殊的行動,找出什麼是真正回事。另外,如何保存從我的費用視圖中生成的多行。我的費用視圖是自定義url,因此可能會導致不顯示sql轉儲,或者這也是不保存數據的原因?請讓我知道我在做什麼錯了?