예제 #1
0
 /**
  * @param Organization $organization
  * @param Party $publisher
  * @return ArrayCollection
  */
 public function booksOfPublisher(Organization $organization, Party $publisher)
 {
     $qb = $this->em->createQueryBuilder();
     $query = $qb->select('b')->from($this->bookClass, 'b')->join('b.publishers', 'p')->where($qb->expr()->eq('p.id', '?1'))->setParameter(1, $publisher->id());
     return $query->getQuery()->getResult();
 }
 /**
  * Destroys a relation that was alive before a given date
  *
  * @param Party $context
  * @param Party $reference
  * @param DateTime $date
  * @param Kind $kind
  */
 public function destroyBefore(Party $context, Party $reference, DateTime $date, Kind $kind)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('pr')->update($this->class, 'pr')->set('pr.end', '?5')->where($qb->expr()->eq('pr.context', '?1'), $qb->expr()->eq('pr.reference', '?2'), $qb->expr()->lt('pr.start', '?3'), $qb->expr()->isNull('pr.end'), $qb->expr()->eq('pr.kind', '?4'))->setParameter(1, $context->id())->setParameter(2, $reference->id())->setParameter(3, $date)->setParameter(4, $kind)->setParameter(5, new DateTime());
     $qb->getQuery()->execute();
 }