我正在使用 dql 来查询我的表。
$dql = "SELECT p FROM WIC\ListingBundle\Entity\Listing p order by p.name";
我有两张桌子,Listing和Products。
在Listing表中,我有product_id引用Products表字段的id字段。
我希望能够通过ProductTablename字段对我的查询进行排序,但我也希望每次这样做时都会出现错误p.name。p.name表中不存在Listing,这就是它抛出错误的原因,我只是不知道如何正确地做到这一点。
Listing实体:
/**
* @ORM\ManyToOne(targetEntity="WIC\ProductBundle\Entity\Product", inversedBy="listings", cascade={"remove","persist"})
* @ORM\JoinColumn(name="product_id", referencedColumnName="id")
* @Common\Versioned
* @Assert\NotBlank()
*/
protected $product;