如何在 pdo_mysql 中使用 NOW() 插入表
当我用 Zend_Db 插入记录时,我尝试使用 mysql NOW() 函数,但它似乎不起作用。 //$transaction 是一个非常正常的 Zend_Db_Table 对象,
$transaction->insert(array('date_created' => 'NOW()')); //inserted 0000-00-00 00:00:00
$transaction->insert(array('date_created' => '2010-12-12 12:12:12')); //inserted 2010-12-12 12:12:12
我很确定我可以使用
$transaction->query()
但想知道我的第一种方法出了什么问题。在 phpmyadmin 中,NOW() 也可以在服务器上工作。
这一切都在 ubuntu 服务器上进行。
I am trying to use mysql NOW() function when I insert a record with Zend_Db but it is not working it seems.
//$transaction is a very normal Zend_Db_Table object
$transaction->insert(array('date_created' => 'NOW()')); //inserted 0000-00-00 00:00:00
$transaction->insert(array('date_created' => '2010-12-12 12:12:12')); //inserted 2010-12-12 12:12:12
I am pretty sure I could do it using
$transaction->query()
But was wondering what was wrong with my first approach. Also NOW() does work on the server when in phpmyadmin.
All this on ubuntu server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用
new Zend_Db_Expr('NOW()')
而不是字符串NOW()
Try
new Zend_Db_Expr('NOW()')
instead of the stringNOW()