无效的PathExpression.必须是StateFieldPathExpression [英] Invalid PathExpression. Must be a StateFieldPathExpression
本文介绍了无效的PathExpression.必须是StateFieldPathExpression的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到的错误是[Semantical Error] line 0, col 57 near 'room FROM AppBundle:bookings': Error: Invalid PathExpression. Must be a StateFieldPathExpression.
我在AppBundle中有两个实体,分别是房间"和预订".一旦执行查询,我就会收到前面提到的错误.
这是我的查询:
I get an error which is [Semantical Error] line 0, col 57 near 'room FROM AppBundle:bookings': Error: Invalid PathExpression. Must be a StateFieldPathExpression.
I have two entities in AppBundle which are Room and Bookings. once I execute the query I get the error mentionned before.
Here my query :
$query = $em->createQuery(
'SELECT r ' .
'FROM AppBundle:Room r ' .
'WHERE r NOT IN ( ' .
'SELECT b.room ' .
'FROM AppBundle:Bookings b ' .
'WHERE NOT ( ' .
'b.check_out < :check_in ' .
'OR ' .
'b.check_in > :check_out ' .
')' .
') ' .
'ORDER BY r.id'
)
->setParameter('check_in', $request->query->get('check-in'))
->setParameter('check_out', $request->query->get('check-out'));
推荐答案
我认为问题出在WHERE NOT
上.
尝试使用以下查询:
I think the problem is about the WHERE NOT
.
try with this query:
$query = $em->createQuery(
'SELECT r ' .
'FROM AppBundle:Room r ' .
'WHERE r NOT IN ( ' .
'SELECT b.room ' .
'FROM AppBundle:Bookings b ' .
'WHERE ' .
'b.check_out < :check_in ' .
'OR ' .
'b.check_in > :check_out ' .
') ' .
'ORDER BY r.id'
)
->setParameter('check_in', $request->query->get('check-in'))
->setParameter('check_out', $request->query->get('check-out'));
这篇关于无效的PathExpression.必须是StateFieldPathExpression的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文