Skip to content

Instantly share code, notes, and snippets.

@Scarbous
Last active May 21, 2025 10:18
Show Gist options
  • Save Scarbous/67f53915d42bd281f4d93f74b44e2f9b to your computer and use it in GitHub Desktop.
Save Scarbous/67f53915d42bd281f4d93f74b44e2f9b to your computer and use it in GitHub Desktop.
TYPO3 extbase get SQL statement from query
<?php
class MyRepository extends Repository
{
function findSome() {
$query = $this->createQuery();
$query->matching(
// ...
);
$queryParser = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($queryParser->convertQueryToDoctrineQueryBuilder($query)->getSQL());
}
}
@a-v-l
Copy link

a-v-l commented May 21, 2025

Today you would use GeneralUtility to get the Typo3DbQueryParser:

$queryParser = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class);

Besides getSQL() the method getParameters() is very helpful. See official documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment