Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine query builder : semantical error

I have a table named "Annonce" that contains some informations about a post ; I would like to retrieve all the "type_bien" (it's a field) already registered in the database by a query. My table has the good field "type_bien", my Entity also.

So I tryed :

$em = $this->get('doctrine')->getEntityManager();
$query = $em->createQuery( 'SELECT DISTINCT type_bien FROM APNegociationBundle:Annonce' );

But I got a semantical error :

[Semantical Error] line 0, col 16 near 'type_bien FROM': Error: 'type_bien' is not defined.

Is there something wrong with my query ?

like image 530
Jérémy Dutheil Avatar asked Dec 04 '11 12:12

Jérémy Dutheil


1 Answers

Problem solved, the good query is :

$query = $em->createQuery( 'SELECT DISTINCT a.type_bien FROM APNegociationBundle:Annonce a' );
like image 125
Jérémy Dutheil Avatar answered Nov 03 '22 00:11

Jérémy Dutheil