2014-11-05 63 views
1

我使用PUGXMulti USer,它是FOSUserBundle的一个扩展,用于处理不同类型的用户。 继步骤文档一步,我创建了实体相关的用户,和其他2个实体(驱动程序,客户端)扩展用户FOSUSER Bundle with many USer + Inheritance

/**@ORM\Entity 
* @ORM\InheritanceType("JOINED") 
* @ORM\DiscriminatorColumn(name="type", type="string") 
* @ORM\DiscriminatorMap({"user_one" = "Dali/FrontBundle/Driver", "user_two" = "Dali/FrontBundle/Client"}) 
* 
*/ 
abstract class User extends BaseUser 
{ 
    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id_user; 

客户端实体入手:

* @ORM\Entity 
* @ORM\Table(name="client") 
*/ 
class Client extends User 
{ 
    /** 
    * @var string 

    */ 
    private $fnameClient; 

我创建了一个FormType为ClientRegistration ,

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 istead t1.username_canonical

+0

查询被用于选择用户不插入一个,所以我想你已经成功注册一个客户,你有问题显示它的权利? – zizoujab 2014-11-05 13:37:16

+0

不,FOSUSerbbundle在插入前查看数据库中是否存在用户名 – Asmaa 2014-11-05 17:37:32

+0

也许你在实体映射中有问题,执行'php app/console doctrine:mapping:info'来检查每个东西是否正常。此外,SQL查询不完整,我认为....隐藏重要的信息来了解问题。 – zizoujab 2014-11-06 12:48:19

回答

0

由于说here

FOSUserBundle is not designed to work with entity inheritance (and you should probably avoid it as it is a performance killer for Doctrine as relational databases are bad at storing inheritance)