2013-02-19 76 views
0

多个$图像在我的数据库,我得到了SonataMediaBundle这个doctrine2 + Symfony2的:在同一实体

table data 
---------- 
id 
name 
description 
image1 
image2 
image3 
key 
... 

和我的实体媒体,我希望把图像在实体介质管理SonataMediaBundle的

如何在我的实体中写入图像的属性?

什么样的意识是?

THX对您有所帮助

回答

1

这仅仅是3次ManyToOne关系(可能)的Image实体。 该实体看起来像下面这样:

class Item 
{ 
    /** 
    * @ORM\Id() 
    * @ORM\GeneratedValue(strategy="AUTO") 
    * @ORM\Column(type="integer") 
    */ 
    protected $id; 

    /** 
    * @ORM\Column(type="string") 
    */ 
    protected $name; 

    /** 
    * @ORM\Column(type="text") 
    */ 
    protected $description; 

    /** 
    * @ORM\ManyToOne(targetEntity="YourNamespace\Entity\Image") 
    */ 
    protected $image1; 

    /** 
    * @ORM\ManyToOne(targetEntity="YourNamespace\Entity\Image") 
    */ 
    protected $image2; 

    /** 
    * @ORM\ManyToOne(targetEntity="YourNamespace\Entity\Image") 
    */ 
    protected $image3; 

    /** 
    * @ORM\Column(type="string") 
    */ 
    protected $key; 

    // ... 
} 
相关问题