Doctrine2 conversion error

后端 未结 4 1428
名媛妹妹
名媛妹妹 2021-02-02 08:14

What does this error from \"Doctrine2 & Symfony2\" mean?

Could not convert database value \"\" to Doctrine Type array

4条回答
  •  不要未来只要你来
    2021-02-02 08:28

    I would prefer not having everyone running SQL on their Production Database.

     @ORM\Column(type="array", nullable=TRUE)
    

    An easier solution in make the Column nullable, so after you run your "console doctrine:schema:update --force" the existing DB entries will get a NULL value, instead of an empty string. And doctrine can handle a converting the database value NULL to Doctrine Type array. It should be just a NULL array reference. And PHP empty() doesn't care if its zero sized array or NULL.

    In MySQL, I get the following sql-dump:

    ALTER TABLE my_table ADD my_new_column LONGTEXT DEFAULT NULL COMMENT '(DC2Type:array)'
    

提交回复
热议问题