Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug a query in extbase?

$query = $this->createQuery();

    return $query->matching($query->like('linker', "$linkerKey=$linkerValue"))
        ->setOrderings(array('crdate' => $ordering))
        ->execute();

How can i debug such a generated query in extbase? When creating the same query again (but without the execute() ) and trying to display it with var_dump or the internal t3lib_div::debug i just receive a blank page.

like image 569
pdu Avatar asked Feb 22 '11 07:02

pdu


2 Answers

In version 8.7 LTS, another way needs to be taken:

$queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getSQL());
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getParameters());
like image 71
pgampe Avatar answered Oct 06 '22 23:10

pgampe


An easy way without changing any Typo3 core code and not mentioned in any forum so far is using the php "serialize()" method:

$result = $query->execute();
echo (serialize($result));

In the result object you find the SQL query (look for "statement;" ...)

like image 31
Benno Avatar answered Oct 06 '22 23:10

Benno