Zend_Db_Expr NOW() 不起作用?
我正在尝试简单的插入:
$data = array
(
'whatever' => 'nevermind',
'etc' => 'more data',
'updated_on' => new Zend_Db_Expr('NOW()')
);
$this->getDbTable()->insert( $data );
所有内容都正确插入,但 updated_on 为空。我做错了什么吗?我知道根据我所说的确定问题可能并不容易,但也许您至少可以建议我如何调试这个问题?预先感谢
。数据库是 mySQL,列是 DATETIME,如果我连接到 mySQL 并手动尝试插入或更新 NOW(),它确实有效。
更新
使用 Profiler,我得到以下输出:
INSERT INTO `db_table` (`column1`, `column2`, `column3`, `column4`, `column5`, `column6`, `column_datetime`, `column7`) VALUES (?, ?, ?, ?, ?, ?, NOW(), ?)
Array
(
[1] => column1 data
[2] => column2 data
[3] => column3 data
[4] => column4 data
[5] => column5 data
[6] => column6 data
[7] => column7 data
)
据我所知,这里一切都很好 :\
Update2: 没关系,我让它工作了。问题完全不同。
I am trying the simple insert:
$data = array
(
'whatever' => 'nevermind',
'etc' => 'more data',
'updated_on' => new Zend_Db_Expr('NOW()')
);
$this->getDbTable()->insert( $data );
Everything gets inserted correctly, but updated_on is null. Am I doing something wrong? I understand it may be not easy to determine the problem from what I said, but maybe you could suggest at least how could I debug this? Thanks in advance
p.s. database is mySQL and column is DATETIME, and if I connect to mySQL and manually try the insert or update NOW(), it does work.
Update
Using Profiler, I get the following output:
INSERT INTO `db_table` (`column1`, `column2`, `column3`, `column4`, `column5`, `column6`, `column_datetime`, `column7`) VALUES (?, ?, ?, ?, ?, ?, NOW(), ?)
Array
(
[1] => column1 data
[2] => column2 data
[3] => column3 data
[4] => column4 data
[5] => column5 data
[6] => column6 data
[7] => column7 data
)
To my knowledge, everything is fine here :\
Update2: Nevermind, I got it working. Problem was entirely different.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅根据您发布的代码,这应该有效。
由于它不起作用,您应该使用 分析器来调试查询:
Based solely on the code you are posting, this should work.
Since it does not, you should use the profiler to debug the query: