一般错误:1364 字段“已创建”没有默认值'在 \lib\Zend\Db\Statement\Pdo.php:238
您好,我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种解决方案可供选择:
更改处理此表单的代码,以便为要保留的对象上的
created
字段设置值。更改架构以定义数据库中
created
列的默认值。CURRENT_TIMESTAMP
是一个有效的默认值,可在插入行时自动将该列设置为当前时间。Two solutions to choose from:
Change the code that processes this form to set a value for the
created
field on the object you're persisting.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.