Cristhian Boujon
Cristhian Boujon

Reputation: 4190

Different table name and entity name in Symfony2

I have an existing database. Lets say that I have a table named "transactions" and I want to create the corresponding Entity named "Transaction". How can I do that?

Upvotes: 16

Views: 15506

Answers (3)

yhu420
yhu420

Reputation: 607

This is still the first result on my web search here is an updated answer for modern Symfony:

#[ORM\Table(name: 'groups')]
class Group
{

Upvotes: 0

Vamsi Krishna B
Vamsi Krishna B

Reputation: 11490

you can set the name of the table using the @ORM\Table annotation

/**
 * @ORM\Entity
 * @ORM\Table(name="transactions")
 */
class Transaction
{

If you don't use Annotations, you can find details about other mappings from this link.

BTW, You can also generate Entities from an Existing Database.

Upvotes: 40

Tuan nguyen
Tuan nguyen

Reputation: 570

You could set name param for mapping http://symfony.com/doc/current/book/doctrine.html#add-mapping-information

Upvotes: -1

Related Questions