2014-05-08 46 views
0

我有問題。我必須將fos_user.id的類型更改爲bigint。但我不知道該怎麼做。我已經重寫了FOSUserBundle,我曾嘗試下面的代碼,它的作品,但不是ID:Symfony2 FOSUserBundle更改fos_user id類型

/** 
* @ORM\Entity 
* @ORM\Table(name="sf_guard_user") 
* @ORM\AttributeOverrides({ 
*  @ORM\AttributeOverride(name="id", [email protected]\Column(type="bigint", name="id")), 
*  @ORM\AttributeOverride(name="email", [email protected]\Column(type="string", name="email_address", length=255)), 
* }) 
*/ 
class User extends BaseUser implements EncoderAwareInterface { 
//... 
} 

回答

2

你並不需要重寫id。它應該在擴展FOS\UserBundle\Model\User的類中定義。只需在User課程中定義它。像這樣:

/** 
* @ORM\Entity 
* @ORM\Table(name="sf_guard_user") 
* @ORM\AttributeOverrides({ 
*  @ORM\AttributeOverride(name="email", [email protected]\Column(type="string", name="email_address", length=255)), 
* }) 
*/ 
class User extends BaseUser implements EncoderAwareInterface { 
    /** 
    * @var integer 
    * 
    * @ORM\Column(name="id", type="bigint") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

//... 
}