I want to subtract a amount from a table's field in Zend Framework. I can run it with SQL using following query:
UPDATE `Person` SET credit=credit-50 where id=1
But how to write above SQL query in Zend Framework?
I want to subtract a amount from a table's field in Zend Framework. I can run it with SQL using following query:
UPDATE `Person` SET credit=credit-50 where id=1
But how to write above SQL query in Zend Framework?
$row = array('credit' => new Zend_Db_Expr('credit - 50'));
$where = "id = 1";
$nRowsAffected = $db->update('Person', $row, $where);
Use Zend_Db_Expr
$data = array(
'credit' => new Zend_Db_Expr('credit - 50'),
);
$n = $db->update('Person', $data, 'id=1');