尝试从 Doctrine 模型生成表并收到 MySQL 错误

发布于 2024-09-16 03:13:28 字数 1132 浏览 16 评论 0原文

Doctrine_Core::createTablesFromModels() 失败并出现以下错误:

  1. 致命错误:未捕获异常“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
  2. 堆栈跟踪:
  3. <代码>#0 /[已删除]/lib/doctrine/Doctrine/Connection.php(1025): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Mysql), 'SELECT a.id...' )
  4. #1 /[已删除]/lib/doctrine/Doctrine/Query/Abstract.php(976): Doctrine_Connection->execute('SELECT a.id...', Array)代码>
  5. #2 /[已删除]/lib/doctrine/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
  6. #3 /[已删除]/app /models/behaviors/IdAsConstant.php(16): Doctrine_Query_Abstract->execute()
  7. #4 /[removed]/ 在线 /[removed]/lib/doctrine/Doctrine/Connection.php第1082章

我认为这种情况正在发生,因为它看到了模型中定义的关系并试图创建约束。但他们正在处理的表尚未创建。我的这个假设正确吗?

有什么我可以尝试修复的吗?

Doctrine_Core::createTablesFromModels() is failing with the following error:

  1. 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
  2. Stack trace:
  3. #0 /[removed]/lib/doctrine/Doctrine/Connection.php(1025): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Mysql), 'SELECT a.id...')
  4. #1 /[removed]/lib/doctrine/Doctrine/Query/Abstract.php(976): Doctrine_Connection->execute('SELECT a.id...', Array)
  5. #2 /[removed]/lib/doctrine/Doctrine/Query/Abstract.php(1026): Doctrine_Query_Abstract->_execute(Array)
  6. #3 /[removed]/app/models/behaviors/IdAsConstant.php(16): Doctrine_Query_Abstract->execute()
  7. #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 技术交流群。

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

发布评论

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

评论(1

暖阳 2024-09-23 03:13:29

当我追查这个错误的根源后,我意识到罪魁祸首是一个不“体贴”的行为模板。

具体来说,该行为假设在执行其 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.

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