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']);
}
}
顧客は正しく更新されますが、住所は常に新しい行を挿入します。このアドレスを更新するにはどうすればよいですか?