Reputation: 331
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
Upvotes: 1
Views: 1981
Reputation: 4908
For Symfony 6, you should use #[ORM\Table("Somename")]
. It should be used like that:
#[ORM\Entity(repositoryClass: SomenameRepository::class)]
#[ORM\Table("Somename")]
class Somename {
// here all your fields
}
Upvotes: 0
Reputation: 331
UPDATE:
Found the solution. I had to write the table name in the Entity like this:
@ORM\Table(name="`Somename`")
Source:
Doctrine - PostgreSQL - Uppercase and Spaces in Table / Field names
Upvotes: 1
Reputation: 10136
You have 2 choices here:
@ORM\Table(name="SomeName")
Upvotes: 1