2011-03-02 110 views
9

我試圖與學說2使用Doctrine 2查詢生成器

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

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

構建查詢出於某種原因,我得到一個錯誤的問題:

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

回答

7

有沒有這樣的事情作爲「全球通配符」 - 您應該使用c.*

9

select('c.*')不適合我,select('c')就夠了