Symfony - 表单生成失败:无法获取未定义表的 TableMap
这是一个令人好奇的问题。我有一个项目已经启动并运行了一段时间 当我向架构添加一个新表时,这才开始。
这些是相关的模式描述。每个表都存在并匹配:
comment:
id:
message: longvarchar
quote_id:
reply_id: { type: integer, foreignTable: comment, foreignReference: id}
created_by: { type: integer, foreignTable: sf_guard_user, foreignReference: id, onDelete: setnull }
created_at:
updated_at:
quote:
id:
account_number:
customer_name:
...
created_at:
updated_at:
contract
id:
account_number: varchar(32)
customer_name: varchar(64)
...
created_at:
updated_at:
contract_comment:
id:
contract_id:
comment_id:
当我运行 ./symfony propel:build --all 时,它会构建模型类, 并开始构建表单类,然后错误提示:
无法获取未定义的 TableMap 表:评论
然而,很明显该表确实存在。如果我删除 模式中的contract_comment条目并重建,注释工作正常。
我在这里查找了遇到此错误的其他用户,但没有他们的解决方案 适用于我的情况。
This is a curious issue. I've had a project up and running for a while,
this only started when I added one new table to the schema.
These are the relevant schema descriptions. Each table exsists and matches:
comment:
id:
message: longvarchar
quote_id:
reply_id: { type: integer, foreignTable: comment, foreignReference: id}
created_by: { type: integer, foreignTable: sf_guard_user, foreignReference: id, onDelete: setnull }
created_at:
updated_at:
quote:
id:
account_number:
customer_name:
...
created_at:
updated_at:
contract
id:
account_number: varchar(32)
customer_name: varchar(64)
...
created_at:
updated_at:
contract_comment:
id:
contract_id:
comment_id:
When I run ./symfony propel:build --all, it builds the model classes,
and starts to build the form classes, then it errors out saying:
Cannot fetch TableMap for undefined
table: comment
However, it's abundantly clear that the table does exist. If I remove
the contract_comment entry from the schema, and rebuild, the comments work fine.
I looked up the other users who ran into this error here, but none of their solutions
apply to my situation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过将评论表重命名为其他名称?
我对名为“project”的表也遇到了类似的问题,因为在尝试构建所有内容时,显然这是 Propel(?) 中的一个特殊词。将其重命名为“jump_project”或任何解决问题的名称。
Have you tried re-naming the comment table to something else?
I had similar problems with a table named "project" because apparently that is a special word in Propel (?) when trying to build everything. Renaming it to jump_project or whatever solved the problem.
我自己刚刚遇到这个问题。
解决方案是更新 Composer 自动加载器以包含新的表类/库/映射。
I just came across this problem myself.
The solution was to update the composer autoloader to include the new table classes/bases/maps.