首页 > 解决方案 > Symfony: Doctrine cannnot find table with first letter Uppercase

问题描述

I have this database in which all tables have this format:

Somedata

and the names of the columns are like this:

UserInformation

Basically, the first letter is capitalized, and Doctrine cannot find the table/column

I tried adding a naming strategy:

naming_strategy: doctrine.orm.naming_strategy.underscore

But that didn't work.

I also tried to set MySQL lower case table names to 1

lower_case_table_names = 1

That didn't work as well. If I change all the names of the tables and columns to lowercase, works as expected. However, I cannot do that in the production database, so how can make Doctrine find the tables with that format?

By the way, the tables are already created, and I cannot modify them

标签: symfonydoctrinesymfony-3.4

解决方案


您在这里有 2 个选择:

  1. 实施自定义命名策略,您可以根据需要生成表名。检查文档Doctrine Naming Strategy
  2. 在每个实体中设置所需的表名:@ORM\Table(name="SomeName")

推荐阅读