我收到此错误[语义错误]第0行,第73行'类LIKE'附近:错误:无效的PathExpression。必须是StateFieldPathExpression

时间:2014-05-06 06:57:38

标签: symfony

以下是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.'%');

请在此处寻求解决方案。

1 个答案:

答案 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.'%');

写下你的代码,你需要给他一个你班级的属性,而不是班级自己。