2013-10-09 43 views
0

我有2個表一對多和多對一的關係在理論

  1. 用戶
  2. 消息

和目錄的結構:

用戶:

enter image description here

消息:

enter image description here

現在看到有存儲在信息表由SENDER_ID識別和receiver_id

我怎樣才能使用戶表和他們的郵件用戶數單這兩個表之間的多對多關係或使用Doctrine/Annotations創建此SQL模式?

回答

1

類似的東西:

/** 
* @ORM\Entity 
* @ORM\Table(name="messages") 
*/ 
class Comment 
{ 
    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

    /** 
    * @ORM\Column(type="string", length=5000, nullable=true) 
    */ 
    protected $text; 


    /** 
    * Author of the comment 
    * 
    * @ORM\ManyToOne(targetEntity="Acme\UserBundle\Entity\User") 
    * @var User 
    */ 
    protected $sender; 

    /** 
    * 
    * 
    * @ORM\ManyToOne(targetEntity="Acme\UserBundle\Entity\User") 
    * @var User 
    */ 
    protected $reciever; 
+0

它應顯示爲用戶2個的關係字符串,以信息在設計模式,但它只是一個展示 –