Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.40 KB | None | 0 0
  1.  
  2.     function loadCollections( )
  3.     {
  4.       $em = $this->em;
  5.       $qb = $em->createQueryBuilder();
  6.      
  7.       $select = array('c','t','p');
  8.       $query = $qb->select($select)
  9.             ->from('com\emeth\web\manager\vo\Collection', 'c')
  10.             ->leftJoin('c.tokens', 't')
  11.             ->leftJoin('c.products', 'p');
  12.            
  13.       return $query->getQuery()->getResult();
  14.     }
  15.  
  16. //need to get products tokens....
  17.  
  18.  
  19. <?php
  20. namespace com\emeth\web\manager\vo;
  21.  
  22. use Doctrine\Common\Collections\ArrayCollection;
  23.  
  24. /**
  25.  * @Entity
  26.  * @author chussenot@gmail.com
  27.  * @Table(name="collection")
  28.  */
  29.  
  30. class Collection {
  31.  
  32.     const STATUS_OFFLINE = 0;
  33.     const STATUS_ONLINE = 1;
  34.        
  35.     /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
  36.     public $id;
  37.  
  38.     /** @Column(length=50, type="string") */
  39.     public $name;
  40.  
  41.     /** @Column(type="smallint") */
  42.     public $status;
  43.    
  44.     /** @Column(length=1000, type="string", nullable=true) */
  45.     public $media;
  46.    
  47.     /** @Column(type="object", nullable=true) */
  48.     public $metas;
  49.    
  50.     /** @OneToMany(targetEntity="Product", mappedBy="collection", cascade={"persist", "remove"}) */
  51.     public $products;
  52.  
  53.      /**
  54.      * @ManyToMany(targetEntity="Token", cascade={"persist", "remove"})
  55.      * @JoinTable(name="collection_token",
  56.      *      joinColumns={@JoinColumn(name="collection_id", referencedColumnName="id")},
  57.      *      inverseJoinColumns={@JoinColumn(name="token_id", referencedColumnName="id")}
  58.      *      )
  59.      */
  60.     public $tokens;
  61.  
  62.     public function __construct() {
  63.         $this->products = new ArrayCollection();
  64.     }
  65.  
  66. }
  67. ?>
  68.  
  69. <?php
  70. namespace com\emeth\web\manager\vo;
  71.  
  72. use Doctrine\Common\Collections\ArrayCollection;
  73.  
  74. /**
  75.  * @Entity
  76.  * @author chussenot@gmail.com
  77.  * @Table(name="product")
  78.  */
  79.  
  80. class Product {
  81.    
  82.     const STATUS_OFFLINE = 0;
  83.     const STATUS_ONLINE = 1;
  84.    
  85.     /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
  86.     public $id;
  87.  
  88.     /** @Column(length=50, type="string") */
  89.     public $name;
  90.  
  91.     /** @Column(type="smallint") */
  92.     public $status;
  93.  
  94.     /** @Column(type="object", nullable=true) */
  95.     public $metas;
  96.    
  97.     /** @Column(length=1000, type="string", nullable=true) */
  98.     public $media;
  99.    
  100.        
  101.     /**
  102.      * @ManyToOne(targetEntity="Collection", inversedBy="products")
  103.      * @JoinColumn(name="collection_id", referencedColumnName="id")
  104.      */
  105.     public $collection;
  106.    
  107.      /**
  108.      * @ManyToMany(targetEntity="Token", cascade={"persist", "remove"})
  109.      * @JoinTable(name="product_token",
  110.      *      joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
  111.      *      inverseJoinColumns={@JoinColumn(name="token_id", referencedColumnName="id")}
  112.      *      )
  113.      */
  114.     public $tokens;
  115.    
  116.     public function __construct() {
  117.     }
  118.  
  119. }
  120. ?>
  121.  
  122. <?php
  123. namespace com\emeth\web\manager\vo;
  124.  
  125. use Doctrine\Common\Collections\ArrayCollection;
  126.  
  127. /**
  128.  * @Entity
  129.  * @author chussenot@gmail.com
  130.  * this class can be use to make RessourceBundle in Flex.
  131.  * @Table(name="token")
  132.  */
  133.  
  134. class Token {
  135.  
  136.     /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
  137.     public $id;
  138.    
  139.     /** @Column(length=255, type="string") */
  140.     public $property;
  141.  
  142.     /** @Column(length=8, type="string") */
  143.     public $language;
  144.  
  145.     /** @Column( type="object") */
  146.     public $value;
  147.  
  148.     /*
  149.     public function __construct($property, $language, $value)
  150.     {
  151.         $this->language = $language;
  152.         $this->property = $property;
  153.         $this->value = $value; 
  154.     }
  155.     */
  156.    
  157.     public function __construct()
  158.     {
  159.  
  160.     }
  161.  
  162.  
  163. }
  164.  
  165. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement