views:

46

answers:

2

What's the way of building "UPDATE table SET date = NOW() WHERE id = 1" query ?

$table->update(array('date' => 'NOW()'), 'id = 1');

Above code doesn't work properly.

+2  A: 
$table->update(array('date' => new Zend_Db_Expr('NOW()'), 'id = 1');

See:

http://framework.zend.com/apidoc/core/Zend_Db/Expr/Zend_Db_Expr.html

karim79
A: 

Did you try using PHP's date function:

$table->update(array('date' => date('Y-m-d H:i:s')), 'id = 1');
Marcin