Doctrine DQL和命名空间(仅相对?) [英] Doctrine DQL and Namespaces (relative only?)
本文介绍了Doctrine DQL和命名空间(仅相对?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到,如果我尝试像
$ query = $ em-> createQuery('SELECT u FROM \Application\Entities\User u');
我得到
[语义错误]行0,col 14靠近'\Application\Entities\User':错误:类'\'未定义。
如果我做
$ query = $ em-> createQuery('SELECT u FROM应用程序\Entities\User u');
它的确定。所以问题是,我可以说DQL只接受DQL语句中的相对命名空间吗?
解决方案
我在 doctrine论坛
它们必须是完全限定类
名称减去开头\
i noticed that if i try to do soemthing like
$query = $em->createQuery('SELECT u FROM \Application\Entities\User u');
i get
[Semantical Error] line 0, col 14 near '\Application\Entities\User': Error: Class '\' is not defined.
if i do
$query = $em->createQuery('SELECT u FROM Application\Entities\User u');
its ok. so the question is, can i say that DQL only accepts relative namespaces in DQL statements?
解决方案
i found the answer at doctrine forums
There are no "relative" namespaces in strings
It must be the fully qualified class name minus the beginning \
这篇关于Doctrine DQL和命名空间(仅相对?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文