Advertisement
Guest User

Avi Block

a guest
Sep 14th, 2009
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. /**
  2.  * @Entity
  3.  * @InheritanceType("JOINED")
  4.  * @DiscriminatorColumn(name="event_type", type="string")
  5.  * @DiscriminatorMap({"auction" = "Auction", "raffle" = "Raffle"})
  6.  */
  7. class Event {
  8.    /**
  9.      * @Id @Column(type="integer")
  10.      * @GeneratedValue(strategy="AUTO")
  11.      */
  12.     private $id;
  13.  
  14.     /**
  15.      * @OneToOne(targetEntity="Organization",cascade={"persist"})
  16.      * @JoinColumn(name="org_id", referencedColumnName="id")
  17.      */
  18.      private $organization;
  19. }
  20.  
  21. class Organization {
  22.    /**
  23.      * @Id @Column(type="integer")
  24.      * @GeneratedValue(strategy="AUTO")
  25.      */
  26.     private $id;
  27.    
  28.     /**
  29.      * @OneToMany(targetEntity="Event", mappedBy="organization")
  30.      */
  31.  
  32.     private $events;
  33.    
  34.     public function getId() {
  35.         return $this->id;
  36.     }
  37. }
  38.  
  39. $q = $em->createQuery('select a from Organization a where a.id = 3');
  40.  
  41. $a = $q->getResult();
  42.  
  43. $events = $a[0]->getEvents();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement