database - ZF Db Append to column -
im trying make update similar zend_db:
update `table` set column = column + 'new value' foo = 'bar' any of have done before? possible? thanks
with of zend_db_expr possible.
example:
$newvalue = 101; $data = array('column' => new zend_db_expr($db->quoteinto('column + ?', $newvalue))); $where = $db->quoteinto('foo = ?', 'bar'); $updated = $db->update('table', $data, $where); resulting query:
update `table` set `column` = `column` + 101 `foo` = 'bar'; if asking how append string, code similar, cannot use + operator when dealing character data, instead use concat().
for example, change $data array this:
$data = array('varcharcol' => new zend_db_expr( $db->quoteinto('concat(varcharcol, ?)', ' append more text!') ));
Comments
Post a Comment