'Target non-existing entity in querybuilder (ManyToMany relationship)
I can't seem to target the JoinTable 'product_features' in a query builder:
/**
* @ORM\ManyToMany(targetEntity="AttributeOption", cascade={"persist"})
* @ORM\JoinTable(name="product_features",
* joinColumns={@ORM\JoinColumn(name="product_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="attribute_option_id", referencedColumnName="id")}
* )
*/
protected $features;
I did discover that you can join a non-related table but you need to call it by the entity in order to do so. Am I right? There is no entity since it's just a table generated by the ManyToMany mapping.
This is what I've tried but it does target the targetEntity 'AttributeOption':
$query
->innerJoin('p.features', 'f')
->setParameter('filters', $filters)
->andWhere('f.id IN (:filters)');
I really need the product_features table in my query. Please, help me out!
Thanks in advance!
Regards, Demi
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
