symfony2 doctrine allow null values?

后端 未结 2 493
一整个雨季
一整个雨季 2021-01-01 08:32

So, I\'m still REALLY new to symfony but i\'m learning quickly... I created an entity and a crud (i forget how I did it actually but it was via the command line)..

2条回答
  •  有刺的猬
    2021-01-01 09:16

    Set your default values directly in the entity file:

    /**
     * @var varchar $totaltime
     */
    private $totaltime = null;
    

    Then add to your yml file:

        totaltime:
            type: string
            nullable: TRUE
    

    Then something like:

    php app/console doctrine:schema:update --dump-sql
    

    To update the database.

    However, you really need to slow down and work you way through the examples in the manual. Guessing at how you did things is really not going to get you very far.

提交回复
热议问题