B
B
BonBon Slick2017-12-10 15:43:36
Doctrine ORM
BonBon Slick, 2017-12-10 15:43:36

How to correctly set the column default value?

@ORM\Column(name="price",  type="decimal", precision=7, scale=2, options={"default" : 0})
// или
 /**
     * @var int
     *
     * @Column(name="price",  type="decimal",   precision=7, scale=2)
     */
    private $price= 0;

Same for nullable, datetime, text, string values.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
voronkovich, 2017-12-10
@BonBonSlick

The second option (or even better is to set the value in the constructor).
The fact is that not all database vendors support the DEFAULT integrity constraint, so such options are placed in the options attribute .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question