开发者

Passing MySQL's CURRENT_TIMESTAMP to Zend_DB update statement

开发者 https://www.devze.com 2023-01-28 22:08 出处:网络
How do I pass mysql\'s CURRENT_TIMESTAMP when using Zend_DB\'s update statement? The following doesnt seem to be working.

How do I pass mysql's CURRENT_TIMESTAMP when using Zend_DB's update statement? The following doesnt seem to be working.

I have something like this:

            $update = array(
                'Name'        =>  'J开发者_开发技巧ohn',
                'DT_Modified'   =>  'CURRENT_TIMESTAMP'
            );

            $db->update('usertable', $update );

to run a query that is represented like this:

UPDATE usertable SET Name='John', DT_Modified = CURRENT_TIMESTAMP


Try using Zend_Db_Expr to avoid unnecessary quoting:

$update = array(
    'Name'        =>  'John',
    'DT_Modified' =>  new Zend_Db_Expr('CURRENT_TIMESTAMP')
);
$db->update('usertable', $update );
0

精彩评论

暂无评论...
验证码 换一张
取 消