一般错误:1364 字段“已创建”没有默认值'在 \lib\Zend\Db\Statement\Pdo.php:238

发布于 2024-10-16 22:17:39 字数 1674 浏览 2 评论 0原文

您好,我正在使用 zend 框架,并使用数据库做一个登录示例...我收到了单击提交按钮后需要填写表单的页面,出现此错误。

 exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY000]: General error: 1364 Field 'created' doesn't have a default value' in C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Statement\Pdo.php:238
Stack trace:
#0 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Adapter\Abstract.php(464): Zend_Db_Statement->execute(Array)
#2 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Adapter\Pdo\Abstract.php(232): Zend_Db_Adapter_Abstract->query('INSERT INTO `re...', Array)
#3 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Adapter\Abstract.php(542): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `re...', Array)
#4 C:\Program Files\Zend\Apache2\htdocs\zend_sample\app\controllers\IndexController.php(47): Zend_Db_Adapter_Abstract->insert('register', Array)
#5 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Controller\Action.php(512): IndexController->indexAction()
#6 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Controller\Dispatcher\Standard.php(288): Zend_Controller_Action->dispatch('indexAction')
#7 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Controller\Front.php(945): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 C:\Program Files\Zend\Apache2\htdocs\zend_sample\www\index.php(37): Zend_Controller_Front->dispatch()
#9 {main}

请帮助我...

Hi i am using zend framework and doing one login example with database...i am getting the page which i need to fill the form after click the submit button getting this error..

 exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[HY000]: General error: 1364 Field 'created' doesn't have a default value' in C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Statement\Pdo.php:238
Stack trace:
#0 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Adapter\Abstract.php(464): Zend_Db_Statement->execute(Array)
#2 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Adapter\Pdo\Abstract.php(232): Zend_Db_Adapter_Abstract->query('INSERT INTO `re...', Array)
#3 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Db\Adapter\Abstract.php(542): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `re...', Array)
#4 C:\Program Files\Zend\Apache2\htdocs\zend_sample\app\controllers\IndexController.php(47): Zend_Db_Adapter_Abstract->insert('register', Array)
#5 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Controller\Action.php(512): IndexController->indexAction()
#6 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Controller\Dispatcher\Standard.php(288): Zend_Controller_Action->dispatch('indexAction')
#7 C:\Program Files\Zend\Apache2\htdocs\zend_sample\lib\Zend\Controller\Front.php(945): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 C:\Program Files\Zend\Apache2\htdocs\zend_sample\www\index.php(37): Zend_Controller_Front->dispatch()
#9 {main}

Please help me.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離殇 2024-10-23 22:17:39

有两种解决方案可供选择:

  1. 更改处理此表单的代码,以便为要保留的对象上的 created 字段设置值。

  2. 更改架构以定义数据库中created 列的默认值。 CURRENT_TIMESTAMP 是一个有效的默认值,可在插入行时自动将该列设置为当前时间。

Two solutions to choose from:

  1. Change the code that processes this form to set a value for the created field on the object you're persisting.

  2. Change the schema to define a default value for the created column in the database. CURRENT_TIMESTAMP is a valid default to automatically set the column to the current time when a row is inserted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文