我有 2 个实体,MyItem 和 MyItemCategory。当我尝试使用查询构建器创建查询时,出现以下错误:
Error: Class App\Entity\MyItem has no
field or association named myitem_category_id (500 Internal Server Error)
这是我的查询构建器的 where 部分:
$queryBuilder = $this->getDoctrine()
->getRepository('App\Entity\MyItem')
->createQueryBuilder('m');
// adds where for category_id:
$queryBuilder->where('m.myitem_category_id = :category_id')->setParameter('category_id',$category_id);
这是第一个实体:
/**
* @ManyToOne(targetEntity="MyItemCategory")
* @JoinColumn(name="myitem_category_id", referencedColumnName="id")
*/
private $myItemCategory;
...和我的类别实体:
/**
* @ORM\OneToMany(targetEntity="MyItem", mappedBy="myItemCategory")
*/
private $myItemCategories;
慕尼黑8549860