2014-11-05 111 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)