In order to debug my code I would like to see the explicit sql query that is executed.
I create the query with createQueryBuilder
, and the most explicit thi
I had to build a requete union (impossible with DQL or QueryBuilder) with 5 query already built with the QueryBuilder. So I reuse these queries but I had a problem using getParameters() function because it give the parameter in same order you have given it. One of the advantages when you use the query builder is you can create a query in order yhou want but when you retrieve parameters, you may retrieve it in messy. to avoid this i have built the following function:
$getSqlWithParams = \Closure::bind(function(){
return [$this->getSql(), $this->processParameterMappings($this->_parserResult->getParameterMappings())];
}, null, Query::class);
now when you want retrieve sql and the sorted parameters you do :
$getSqlWithParams()->call($query)
Don't forget use \Doctrine\ORM\Query statement. And voilà!