I know I can use $this->Model->save() to update a particular record if I pass the id in, but how can I update a single field on that row?
I have a users table with a balance field. I want to update the balance field based on what’s already there.
For example, a user has $20 in the balance field. I want to add $1 to make it $21. The only way I know how to do this is to use
$balance = $this->Model->find('first', array(
'conditions' => array('User.id' => $userId),
'fields' => array('User.balance')
));
$this->Model->save(array(
'User' => array('id' => $userId, 'balance' => $balance['User']['balance'] + $credit)
));
How can I get that all into one save call?
try this:-