使用 cakephp:我正在尝试更新客户信息和客户链接的地址。这样 Customer.address_id = Address.id,并且
客户模型
$belongsTo = 'Address';
来自customers_controller
function profile($id = null)
{
if (empty($this->data['Customer']))
{
$this->Customer->id = $id;
$this->data = $this->Customer->read();
}
else
{
$this->Customer->id = $this->data['Customer']['id'];
$this->Customer->read();
$this->Customer->save($this->data['Customer']);
$this->Customer->Address->save($this->data['Address']);
}
}
客户正确更新,但地址总是插入一个新行。我如何让这个地址更新?