我有一个有效的应用程序。现在我想将实体的表名从 CamelCase 更改为 underscore_case。
旧代码:
/**
* @ORM\Table(name="FeaturedProduct")
*/
class FeaturedProduct
{ ... }
一切正常
新代码:
/**
* @ORM\Table(name="featured_product")
*/
class FeaturedProduct
{ ... }
现在我得到:
渲染模板期间抛出异常:
("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myapp.FeaturedProduct' doesn't exist") in MyApp::layout_user_2_col.html.twig at line 37.
MyApp/Resources/views/layout_user_2_col.html.twig:37
{% render "MyApp:FeaturedProduct:random" %}
文件 MyApp/Resources/views/FeaturedProduct/random.html.twig 存在。
看起来 twig 使用表名称作为模板的路径,而不是 Controller 的名称。
最佳答案
您似乎尚未更新架构。
使用以下命令查看应进行哪些更改才能同步架构和实体注释:
app/console doctrine:schema:update --dump-sql
并运行以下命令来实际进行此更改
app/console doctrine:schema:update --force
关于Symfony2、twig 模板和 @ORM\Table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10988408/