"invoice"와 "subscription"이 many to many 관계에 있도록 "subscription"이 많은 "invoice"라는 엔티티가 있습니다. querybuilder를 사용Doctrine 배열이있는 where 절
class Invoice
{
/**
* @ORM\Column(type="integer")
*/
protected $a;
/**
* @ORM\Column(type="integer")
*/
protected $b;
/**
* @ORM\ManyToMany(targetEntity="Subscription", inversedBy="invoices")
*/
protected $subscriptions;
public function __construct()
{
$this->subscriptions = new ArrayCollection();
}
//typical setters and getters
}
, 어떻게 subcription에 where 절을 사용하여 개체를 일치 세트를받을 수 있나요?
$subscription = ;//something pulled from the db and is a "subscription" object
$em->createQueryBuilder()
->select('p')
->from('Invoice', 'p')
->where('p.a = :a')
->andWhere('p.b = :b')
->andWhere('p.subscriptions has :subscription') //this line here I need help
->setParameter('a', 1)
->setParameter('b', 2)
->setParameter('subscription', $subscription)
->getQuery()
->getResult();