Symfony - 期望StateFieldPathExpression或SingleValuedAssociationField

时间:2017-07-25 15:46:53

标签: symfony doctrine query-builder

我使用Symfony的查询构建器,我有这个查询:

->select('partial detail.{id}')
->from('Shopware\Models\Article\Detail', 'detail')
->innerJoin('detail.attribute', 'attr')
->leftJoin('detail.article', 'article')

现在我有一个超出此范围的自定义模型,具有以下关系:

class Supplier {
    /**
     * @var \Shopware\Models\Article\Supplier
     * @ORM\ManyToMany(targetEntity="\Shopware\Models\Article\Supplier")
     * @ORM\JoinTable(name="fp_demand_planning_supplier_manufacturers", joinColumns={@ORM\JoinColumn(name="supplier_id", referencedColumnName="id")}, inverseJoinColumns={@ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id", unique=true)})
     */
    private $manufacturers;

在文章方面,模型\Shopware\Models\Article\Supplier存储在article.supplier

所以现在我想用上面的查询加入我的自定义模型,如下所示:

->select('partial detail.{id}')
->from('Shopware\Models\Article\Detail', 'detail')
->innerJoin('detail.attribute', 'attr')
->leftJoin('detail.article', 'article')
->innerJoin('FpDemandPlanning\Models\Supplier', 'fps', 'WITH', 'article.supplier = fps.manufacturers');

我收到此错误:

206 near 'manufacturers': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected. 

我也是这样试过的:

->innerJoin('FpDemandPlanning\Models\Supplier', 'fps', 'WITH', 'article.supplier IN (fps.manufacturers)');

但后来我收到了这个错误:

[Syntax Error] line 0, col 216: Error: Expected Literal, got 'fpSupplier' in

有人知道如何加入这里有多对多关系的自定义模型吗?

谢谢!

0 个答案:

没有答案