使用 Zend Date 将当前日期插入 MySql
我有一个基于 Zend 框架的网站。有一个表格供用户填写,输入的数据将插入数据库中。
用户不输入日期/时间。我想根据当前日期/时间填充数据值。日期字段的类型为日期时间。
我不断收到以下错误消息:
Notice: Array to string conversion in D:\wamp\www\CNFSORG\library\Zend\Db\Statement\Pdo.php on line 228
我已尝试执行以下操作:
<?php $date = new Zend_Date(); ?>
也尝试执行以下操作:
<?php $date = new Zend_Db_Expr('NOW()'); ?>
<?php $date = new Zend_Db_Expr('CURDATE()'); ?>
如果有人能指出我正确的方向,我将非常感激。
提前致谢...
I have a website based on Zend Framework. There is a form for users to fill in and the entered data is inserted in the database.
The users don't enter the date/time. I would like to populate the data value based on the current date/time . The date field is of type datetime.
i'm constantly getting the following error message:
Notice: Array to string conversion in D:\wamp\www\CNFSORG\library\Zend\Db\Statement\Pdo.php on line 228
I have tried doing the following:
<?php $date = new Zend_Date(); ?>
also tried doing:
<?php $date = new Zend_Db_Expr('NOW()'); ?>
<?php $date = new Zend_Db_Expr('CURDATE()'); ?>
I would be very grateful if someone could point me towards the right direction.
thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正确的答案是
你可以尝试使用类似的东西从 php 创建当前时间戳
The Correct answer is
You can try create a current timestamp from php with something like that
好吧,我已经为 SqlServer 完成了此操作,但我认为对于 MySql,您只需要更改您想要的数据库表达式即可。
希望有帮助。
Well, i'v done this for SqlServer, but i think that for MySql you just need to change the db-expression for the one you want.
Hope it helps.
在您的表类中使用以下代码:
如果您有一列名称为
tme
且类型为datetime
,则此代码将执行您想要的操作!In your class of table use this code:
If you have a column with
tme
name and type ofdatetime
, this code will do what you want!