Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with Doctrine 2 Query Builder

Tags:

doctrine-orm

I'm trying to build a query with Doctrine 2

$qb = $em->createQueryBuilder()
                  ->select('*')
                  ->from('Countries','c')
                  //getDQL
                  ->getQuery();

  echo "<pre>";
echo ($qb->execute());
echo "</pre>";
die;

for some reason I'm getting an error:

Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 7: Error: Expected IdentificationVariable | StateFieldPathExpression | AggregateExpression | "(" Subselect ")" | ScalarExpression, got '*'' in /home/dodo/doctrine-orm/Doctrine/ORM/Query/QueryException.php on line 42

like image 430
Asaf Avatar asked Mar 02 '11 18:03

Asaf


2 Answers

There is no such a thing as "global wildcard" - you should use c.*.

like image 126
Crozin Avatar answered Nov 12 '22 15:11

Crozin


select('c.*') didn't work for me, select('c') was enough

like image 29
Diogyn Avatar answered Nov 12 '22 13:11

Diogyn