开发者

Passing MySQL's CURRENT_TIMESTAMP to Zend_DB update statement

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜