Vincent
Vincent

Reputation: 3

Doctrine 2 - Prefix column in database (sf4)

I'm trying to achieve something which looks like a bit hard to me.

I have an entity "User". I wrote the following anotations to get a 'usr' prefix on the table : "@ORM\Table(name="usr_user")"

I wonder if i can add a prefix on each column of my table but not in an hard way. I mean, i'd like to have my entity clean and not having to deal with things like 'getUsrName' instead of 'getName' (in case my column name have a prefix usr).

Is there an easy way to do so ? I saw a lot of thing about removing prefix on column but not the reverse.

Thanks for your help !

Upvotes: 0

Views: 574

Answers (1)

Jose M. González
Jose M. González

Reputation: 15110

You can do it in the same way, each property can be named with the name parameter.

I hope this example can help you

/** @Column(name="prefix_number", type="integer") */

private $number;

Doctrine documentation

Upvotes: 1

Related Questions