开发者

Zend Framework Table insert MySQL Expression

Just wanted to ask if there is an easyer way to do this (to use the FROM_UNIXTIME expression):

$table = $this->getDbTable();
$db = $table->getAdapter();

$table->insert(array(
    'date'=>new Zend_Db_Expr($db->quoteInto('FROM_UNIXTIME(?)', time())),
    'name'=>$name,
    'password'=>'',
    'passworddate'=>'0000-00-00 00:00:00'
));

I mean it's a lot overhead just to use FROM_UNIX开发者_Go百科TIME. And it's looks not very clean in my opptinion.


You can simply use MySQL's NOW() function unless there's a time difference between your application and database servers.

'date' => new Zend_Db_Expr('NOW()'),

If the application server time takes priority, why not simply try

'date' => date('Y-m-d H:i:s'),
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜