smoreno
smoreno

Reputation: 3530

How to manage Mysql YEAR type with doctrine 2

I need a field for store only a year, not a complete date. Can I manage mysql YEAR type with doctrine 2?

Upvotes: 3

Views: 3962

Answers (2)

MDrollette
MDrollette

Reputation: 6927

That mapping doesn't currently exist. You will have to use a string or a date field. Or create you own mapping. I don't know the exact steps needed. But these references can hopefully help.

http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types

Upvotes: 3

Roberto Rizzi
Roberto Rizzi

Reputation: 1543

I tried it and work fine:

/**
 * @var \Year
 *
 * @ORM\Column(name="year_born", columnDefinition="YEAR", nullable=false)
 */
private $yearBorn;

Upvotes: 0

Related Questions