yamcsha

ManyToMany Bidirectional - Doctrine2

Apr 24th, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. namespace Entity;
  3.  
  4. /**
  5.  * User
  6.  *
  7.  * @Table(name="user")
  8.  * @Entity
  9.  */
  10. class User
  11. {  
  12.     /**
  13.      * Bidirectional - Many users have Many favorite comments (OWNING SIDE)
  14.      *
  15.      * @ManyToMany(targetEntity="Entity\Comment", inversedBy="userFavorites")
  16.      * @JoinTable(name="user_favorite_comments",
  17.      *   joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
  18.      *   inverseJoinColumns={@JoinColumn(name="favorite_comment_id", referencedColumnName="id")}
  19.      * )
  20.     */
  21.     private $favorites;
  22.  
  23. class Comment
  24. {
  25.     /**
  26.      * Bidirectional - Many comments are favorited by many users (INVERSE SIDE)
  27.      *
  28.      * @ManyToMany(targetEntity="Entity\User", mappedBy="favorites")
  29.      */
  30.     private $userFavorites;
Advertisement
Add Comment
Please, Sign In to add comment