Jér*_*eil 5 symfony doctrine-orm
我有一个名为"Annonce"的表,其中包含有关帖子的一些信息; 我想通过查询检索已经在数据库中注册的所有"type_bien"(它是一个字段).我的桌子有好的字段"type_bien",我的实体也是.
所以我尝试了:
$em = $this->get('doctrine')->getEntityManager();
$query = $em->createQuery( 'SELECT DISTINCT type_bien FROM APNegociationBundle:Annonce' );
Run Code Online (Sandbox Code Playgroud)
但我得到了一个语义错误:
[Semantical Error] line 0, col 16 near 'type_bien FROM': Error: 'type_bien' is not defined.
Run Code Online (Sandbox Code Playgroud)
我的查询有问题吗?
Jér*_*eil 14
问题解决了,好的查询是:
$query = $em->createQuery( 'SELECT DISTINCT a.type_bien FROM APNegociationBundle:Annonce a' );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10046 次 |
| 最近记录: |