1
所以,我在CakePHP中使用的形式是表单助手。这种形式有两种相关模型:预订&访客。数据库表似乎设置正确,因为页面通过模型中的关联足够准确地填充值。CakePHP的 - 相关数据不保存(但主模型数据并保存)
当保存我的表单数据,订阅信息保存而不是客户的信息。我简化了下面代码片段中的代码。任何想法我做错了什么?
型号
class Booking extends AppModel {
public $name = "Booking";
/*Associations Section*/
public $belongsTo = array('Property','Bookingsource');
public $hasMany = array('Payment','Occupant','Bookingfee');
public $hasAndBelongsToMany = array(
'Addon',
'Guest' => array(
'unique' => FALSE
)
);
}
控制器
public function edit($id) {
if ($this -> request -> is('post')) {
if ($this -> Booking -> saveAll($this -> request -> data)) {
$this -> Session -> setFlash('Booking Edited Successully!', "goodflash");
} else {
$this -> Session -> setFlash('Oops Something went wrong!', "badflash");
}
} else {
$this->data = $this -> Booking -> findById($id);
$this -> set('bookingid', $id);
}
}
查看
<?php
echo $this->Form->create("Booking", array('type' => 'post'));
echo $this -> Form -> hidden('Booking.id');
echo $this -> Form -> input('Booking.property_id');
echo $this -> Form -> input('Booking.checkin');
echo $this -> Form -> input('Booking.checkout');
echo $this -> Form -> input('Guest.0.firstname');
echo $this -> Form -> end("Submit");
?>
当那就是BEING亲SQL看奇怪,我没有看到任何建议尝试编辑附加到我的模型的宾客表。
5 UPDATE `cake_bookingsystem`.`bookings` SET `id` = '10000', `property_id` = '01', `checkin` = '2012-11-10', `checkout` = '2012-12-13' WHERE `cake_bookingsystem`.`bookings`.`id` = '10000' 0 0 8
6 COMMIT 0 0 8
尝试添加了ID字段?仍然没有运气。再次,对主要预订信息的任何更改都会提交,但对客人的任何更改都不会执行任何操作。令人沮丧! –
我还编辑我的问题有点包括 –
在所有被写入到客户机表中的任何数据,而编辑或添加SQL? –