How do i force cake to update a field and not insert a new record.
It should fail if the id does not exist in the db
I found to force a insertion i can do 'updated' => false
so if i do 'updated' => true
will it work
If you want to just update a field, use the saveField
method of the model
$this->Order->id = $id;
$this->Order->saveField('status', 'VOID');
Reference : 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);
see http://book.cakephp.org/2.0/en/models/saving-your-data.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With