我有三个桌子。 收集表,ShopProductCollection表和ShopProductTabe。
我需要一系列产品。
我尝试了一个示例,该示例生成了一个具有相关ID的新表,但无法弄清楚如何正确使用它来获取我的产品集合。
我的实体:
**
* @ORM\Entity
* @ORM\Table(name="collections")
*/
class Collection extends BaseEntity
{
/**
* @var \Doctrine\Common\Collections\Collection|CollectionShopProduct[]
*
* @ORM\ManyToMany(targetEntity="App\Base\Entity\Shop\CollectionShopProduct", inversedBy="collection")
* @ORM\JoinTable(
* name="collections_shop_product",
* joinColumns={
* @ORM\JoinColumn(name="collection_id", referencedColumnName="collection")
* },
* inverseJoinColumns={
* @ORM\JoinColumn(name="shop_product_id", referencedColumnName="shopProduct")
* }
* )
*/
protected $products;
/**
* Default constructor, initializes collections
*/
public function __construct()
{
$this->products = new ArrayCollection();
}
...
/**
* @ORM\Entity
* @ORM\Table(name="collections_shop_product")
*/
class CollectionShopProduct extends BaseEntity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"collection_shop_product_data"})
*/
protected $id;
/**
* @var \Doctrine\Common\Collections\Collection|Collection[]
*
* @ORM\ManyToMany(targetEntity="App\Base\Entity\Shop\Collection", mappedBy="products")
*/
private $collection;
/**
* @ORM\ManyToOne(targetEntity="LaunchPad\Base\Entity\Shop\ShopProduct")
* @JoinColumn(name="shop_product_id", referencedColumnName="id", nullable=true)
* @Groups({"collection_shop_product_data"})
*/
private $shopProduct;
有人可以帮我发疯吗?