I’d like to increment the value of a column in cakePHP.
Is there a way to have cakePHP write this?
UPDATE `gigs` SET `visits` = visits+1 WHERE `gigs`.`id` = 1
I tried this:
function addVisit($id){
$this->id = $id;
$this->saveField('visits', 'visits+1');
}
but cakePHP adds quotes around visits+1.
UPDATE `gigs` SET `visits` = 'visits+1' WHERE `gigs`.`id` = 1
I tried double quotes, results the same.
or
one of them should work, saveField does not allow sql fragments, updateAll does