Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadCollections( )
- {
- $em = $this->em;
- $qb = $em->createQueryBuilder();
- $select = array('c','t','p');
- $query = $qb->select($select)
- ->from('com\emeth\web\manager\vo\Collection', 'c')
- ->leftJoin('c.tokens', 't')
- ->leftJoin('c.products', 'p');
- return $query->getQuery()->getResult();
- }
- //need to get products tokens....
- <?php
- namespace com\emeth\web\manager\vo;
- use Doctrine\Common\Collections\ArrayCollection;
- /**
- * @Entity
- * @author chussenot@gmail.com
- * @Table(name="collection")
- */
- class Collection {
- const STATUS_OFFLINE = 0;
- const STATUS_ONLINE = 1;
- /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
- public $id;
- /** @Column(length=50, type="string") */
- public $name;
- /** @Column(type="smallint") */
- public $status;
- /** @Column(length=1000, type="string", nullable=true) */
- public $media;
- /** @Column(type="object", nullable=true) */
- public $metas;
- /** @OneToMany(targetEntity="Product", mappedBy="collection", cascade={"persist", "remove"}) */
- public $products;
- /**
- * @ManyToMany(targetEntity="Token", cascade={"persist", "remove"})
- * @JoinTable(name="collection_token",
- * joinColumns={@JoinColumn(name="collection_id", referencedColumnName="id")},
- * inverseJoinColumns={@JoinColumn(name="token_id", referencedColumnName="id")}
- * )
- */
- public $tokens;
- public function __construct() {
- $this->products = new ArrayCollection();
- }
- }
- ?>
- <?php
- namespace com\emeth\web\manager\vo;
- use Doctrine\Common\Collections\ArrayCollection;
- /**
- * @Entity
- * @author chussenot@gmail.com
- * @Table(name="product")
- */
- class Product {
- const STATUS_OFFLINE = 0;
- const STATUS_ONLINE = 1;
- /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
- public $id;
- /** @Column(length=50, type="string") */
- public $name;
- /** @Column(type="smallint") */
- public $status;
- /** @Column(type="object", nullable=true) */
- public $metas;
- /** @Column(length=1000, type="string", nullable=true) */
- public $media;
- /**
- * @ManyToOne(targetEntity="Collection", inversedBy="products")
- * @JoinColumn(name="collection_id", referencedColumnName="id")
- */
- public $collection;
- /**
- * @ManyToMany(targetEntity="Token", cascade={"persist", "remove"})
- * @JoinTable(name="product_token",
- * joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
- * inverseJoinColumns={@JoinColumn(name="token_id", referencedColumnName="id")}
- * )
- */
- public $tokens;
- public function __construct() {
- }
- }
- ?>
- <?php
- namespace com\emeth\web\manager\vo;
- use Doctrine\Common\Collections\ArrayCollection;
- /**
- * @Entity
- * @author chussenot@gmail.com
- * this class can be use to make RessourceBundle in Flex.
- * @Table(name="token")
- */
- class Token {
- /** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
- public $id;
- /** @Column(length=255, type="string") */
- public $property;
- /** @Column(length=8, type="string") */
- public $language;
- /** @Column( type="object") */
- public $value;
- /*
- public function __construct($property, $language, $value)
- {
- $this->language = $language;
- $this->property = $property;
- $this->value = $value;
- }
- */
- public function __construct()
- {
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement