如何强制蛋糕更新字段而不插入新记录.
如果db中不存在id,它应该失败
我发现强制插入我可以这样做'updated' => false,如果我这样做'updated' => true它会工作
Joh*_*hnP 17
如果您只想更新字段,请使用saveField模型的方法
$this->Order->id = $id;
$this->Order->saveField('status', 'VOID');
Run Code Online (Sandbox Code Playgroud)
参考:http://book.cakephp.org/2.0/en/models/saving-your-data.html
//Create: id isn't set or is null
$this->Recipe->create();
$this->Recipe->save($this->data);
//Update: id is set to a numerical value
$this->Recipe->id = 2;
$this->Recipe->save($this->data);
Run Code Online (Sandbox Code Playgroud)
请参阅http://book.cakephp.org/2.0/en/models/ saving -your-data.html