When having errors in my queries, the exception which is thrown by Symfony2 is, in most cases, not very helpful, because it lacks the context, that is: the query which triggered the error:
[Syntax Error] line 0, col 74: Error: Expected =, <, <=, <>, >, >=, !=, got ‘d’
Is there a way to do something like that:
... catch(\Exception $exception){
if(get_class($exception) == 'Doctrine\ORM\Query\QueryException'){
/* var $exception \Doctrine\ORM\Query\QueryException */
var_dump($exception->getSqlQuery());
}
...
That would improve debugging A LOT!
This should now be built-in doctrine, since this commit https://github.com/doctrine/doctrine2/commit/d05ad996c4c3acfd3a0c8659719dd4752cb84531 (commited in master).
I guess it may be release in doctrine 2.3