以下是p.classes是外键的代码。当查询将触发时,它会显示如下错误:
语义错误]第0行,第73行附近'类LIKE':错误:无效 PathExpression。必须是StateFieldPathExpression。
$query = $this->getEntityManager()
->createQuery('SELECT p FROM StudentBundle:Student p WHERE p.classes LIKE :name')
->setParameter('name','%'.$keyword.'%');
请在此处寻求解决方案。
答案 0 :(得分:1)
$em = $this->getEntityManager();
$query = $em->createQuery(
'Select p
From StudentBundle:Student p
Where p.classes c
And c.name LIKE :name');
$query->setParameter('name','%'.$keyword.'%');
写下你的代码,你需要给他一个你班级的属性,而不是班级自己。