SQL update query in Zend Framework

entity-framework sql sql-update zend-framework

Question

How would I write this SQL the Zend Framework way?

UPDATE register 
SET balance = (balance + 10) 
WHERE added_date > 1259944184 ;

I can't find any examples of this on Zend's website or the web.

Do I need to use "Zend_Db_Expr"?

1
2
5/3/2012 10:33:28 AM

Accepted Answer

acording to zend framwork documentation

use this

$data = array(
    'balance'      => 'balance + 10'
);

$n = $db->update('register ', $data, 'added_date > 1259944184');
1
12/4/2009 9:28:01 PM

Popular Answer

This worked for me:

$data = array(balance => new Zend_DB_Expr('balance + 10'));

$db->update('register ', $data, 'added_date > 1259944184');


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow