Default value in Doctrine

Jiew Meng picture Jiew Meng · Jul 31, 2010 · Viewed 318.2k times · Source

How do I set a default value in Doctrine 2?

Answer

iv3ndy picture iv3ndy · Aug 2, 2012
<?php
/**
 * @Entity
 */
class myEntity {
    /**
     * @var string
     *
     * @ORM\Column(name="myColumn", type="integer", options={"default" : 0})
     */
    private $myColumn;
    ...
}

Note that this uses SQL DEFAULT, which is not supported for some fields like BLOB and TEXT.