具有多个USer+继承的FOUSERbundle



我使用PUGXMulti-USer,它是FOSUserBundle处理不同类型用户的扩展。按照文档STep by STep,我创建了我的实体USER,另外两个实体(驱动程序、客户端)扩展了USER

/**@ORMEntity
 * @ORMInheritanceType("JOINED")
 * @ORMDiscriminatorColumn(name="type", type="string")
 * @ORMDiscriminatorMap({"user_one" = "Dali/FrontBundle/Driver", "user_two" = "Dali/FrontBundle/Client"})
 *
 */
abstract class User extends BaseUser
{
    /**
     * @ORMId
     * @ORMColumn(type="integer")
     * @ORMGeneratedValue(strategy="AUTO")
     */
    protected $id_user;

客户端实体以开头

* @ORMEntity
 * @ORMTable(name="client")
*/
class Client extends User
{
    /**
     * @var string
     */
    private $fnameClient;

我为ClientRegistration创建了一个FormType,

class ClientFormType extends AbstractType {
     public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('fnameClient');
        $builder->add('username');
        $builder->add('email');

问题是当我提交表格时,它给了我错误:

An exception occurred while executing 'SELECT t1.username AS username2, t1.username_canonical AS username_canonical3, .... FROM client t1 WHERE t0.username_canonical = ?' with params ["az"]:

我想说的是,他为什么要做where t0.username_canonical而不是t1.username_canonical

如前所述:

FOSUserBundle不是为处理实体继承而设计的(您可能应该避免它,因为它是Doctrine的性能杀手,因为关系数据库不善于存储继承)

相关内容

  • 没有找到相关文章

最新更新