尝试从 Doctrine 模型生成表并收到 MySQL 错误
Doctrine_Core::createTablesFromModels() 失败并出现以下错误:
致命错误:未捕获异常“Doctrine_Connection_Mysql_Exception”,消息为“SQLSTATE[42S02]:未找到基表或视图:1146 表“newmexicocreates.address_type”不存在。查询失败:“SELECT a.id AS a__id, a.title AS a__title FROM address_type a”' in /[removed]/lib/doctrine/Doctrine/Connection.php:1082
堆栈跟踪:
- <代码>#0 /[已删除]/lib/doctrine/Doctrine/Connection.php(1025): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Mysql), 'SELECT a.id...' )
#1 /[已删除]/lib/doctrine/Doctrine/Query/Abstract.php(976): Doctrine_Connection->execute('SELECT a.id...', Array)
代码>#2 /[已删除]/lib/doctrine/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
#3 /[已删除]/app /models/behaviors/IdAsConstant.php(16): Doctrine_Query_Abstract->execute()
#4 /[removed]/ 在线 /[removed]/lib/doctrine/Doctrine/Connection.php第1082章
我认为这种情况正在发生,因为它看到了模型中定义的关系并试图创建约束。但他们正在处理的表尚未创建。我的这个假设正确吗?
有什么我可以尝试修复的吗?
Doctrine_Core::createTablesFromModels() is failing with the following error:
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'newmexicocreates.address_type' doesn't exist. Failing Query: "SELECT a.id AS a__id, a.title AS a__title FROM address_type a"' in /[removed]/lib/doctrine/Doctrine/Connection.php:1082
Stack trace:
#0 /[removed]/lib/doctrine/Doctrine/Connection.php(1025): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Mysql), 'SELECT a.id...')
#1 /[removed]/lib/doctrine/Doctrine/Query/Abstract.php(976): Doctrine_Connection->execute('SELECT a.id...', Array)
#2 /[removed]/lib/doctrine/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
#3 /[removed]/app/models/behaviors/IdAsConstant.php(16): Doctrine_Query_Abstract->execute()
#4 /[removed]/ in /[removed]/lib/doctrine/Doctrine/Connection.php on line 1082
I think this is happening because it's seeing relationships defined in the models and trying to create constraints. But the tables they're dealing with haven't been created yet. Am I correct in this assumption?
Is there anything I can try to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我追查这个错误的根源后,我意识到罪魁祸首是一个不“体贴”的行为模板。
具体来说,该行为假设在执行其 setUp 方法时该表存在。
After I traced this error to its source, I realized that the culprit was a behavior template that wasn't being "considerate".
Specifically, the behavior was assuming that the table existed while executing its setUp method.