使用 FOSUserBundle、Symfony2 和 Doctrine,我试图在用户实体中引入一个新字段。
到目前为止,我还没有遇到问题自定义用户实体以添加“正常”类型的字段,例如字符串、布尔值等...
但是现在我想添加一个“数组”类型的字段,只是我在其他实体中制作的。
这是我在用户实体中介绍的代码:
/**
* @var array $archivedPackages
*
* @ORM\Column(name="archivedPackages", type="array")
*/
private $archivedPackages;
但是,一旦我重新生成实体 ( doctrine:generate:entities
) 后重新加载我的页面,我就会收到以下错误:
ConversionException: Could not convert database value "" to Doctrine Type array
堆栈:
in /Users/pgbonino/Sites/Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/ConversionException.php line 46
at ConversionException::conversionFailed() in /Users/pgbonino/Sites/Symfony/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/ArrayType.php line 48
at ArrayType->convertToPHPValue() in /Users/pgbonino/Sites/Symfony/vendor/doctrine/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 85
at SimpleObjectHydrator->_hydrateRow() in /Users/pgbonino/Sites/Symfony/vendor/doctrine/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 43
at SimpleObjectHydrator->_hydrateAll() in /Users/pgbonino/Sites/Symfony/vendor/doctrine/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php line 99
at AbstractHydrator->hydrateAll() in /Users/pgbonino/Sites/Symfony/vendor/doctrine/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 582
at BasicEntityPersister->load() in /Users/pgbonino/Sites/Symfony/vendor/doctrine/lib/Doctrine/ORM/EntityRepository.php line 181
at EntityRepository->findOneBy() in /Users/pgbonino/Sites/Symfony/vendor/bundles/FOS/UserBundle/Entity/UserManager.php line 69
at UserManager->findUserBy() in /Users/pgbonino/Sites/Symfony/vendor/bundles/FOS/UserBundle/Model/UserManager.php line 79
at UserManager->findUserByUsername() in /Users/pgbonino/Sites/Symfony/vendor/bundles/FOS/UserBundle/Model/UserManager.php line 141
at UserManager->loadUserByUsername() in /Users/pgbonino/Sites/Symfony/vendor/bundles/FOS/UserBundle/Model/UserManager.php line 127