Different table name and entity name in Symfony2

Cristhian Boujon picture Cristhian Boujon · Jul 30, 2015 · Viewed 8.5k times · Source

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?

Answer

Vamsi Krishna B picture Vamsi Krishna B · Jul 30, 2015

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.