Photo of Torben Hansen

A TechBlog by Torben Hansen


Freelance Full Stack Web Developer located in Germany.
I create web applications mainly using TYPO3, PHP, Python and JavaScript.
Home Archive Tags

TYPO3 - get resulting SQL from Extbase query

When you develop a TYPO3 Extbase extension, you may sometimes wonder, why a query does not return the exprected results. In this situation, it would be great if you can get the resultig SQL from TYPO3.

Actually, there are some solutions on the internet for this problem. Sadly, the one I found here does not work for me in TYPO3 6.0. The code snippet found here pointed me to the right direction. There is only one problem with the snippet, since it does not contain the whole SQL query (some parameters are filled with a questionmark).

So here is hopefully a complete solution on how to output the resulting SQL from an Extbase query.

Attention: The following code changes should only be done for development purposes on development systems.

  1. Open the file "/typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbBackend.php"
  2. Navigate to the function "GetObjectDataByQuery()"
  3. Go to the line next to "$this->replacePlaceholders($sql, $parameters, $tableName);"
  4. Insert the following code 

var_dump($sql);

This should output the resulting SQL query. Please notice, that this change can result in more than just one SQL query output, since now every query processed by Extbase is printed out.

If anyone has another solution for this problem, feel free to drop me a message.

Happy debugging :-)