Skip to content

Instantly share code, notes, and snippets.

@fchaussin
Last active February 24, 2022 10:47
Show Gist options
  • Save fchaussin/449d878607f28746d8e8485e74a5dbd0 to your computer and use it in GitHub Desktop.
Save fchaussin/449d878607f28746d8e8485e74a5dbd0 to your computer and use it in GitHub Desktop.
Debug SQL Queries in TYPO3 Repository (Extbase)
function debug($query){
$doctrineObj = $this->objectManager
->get(\TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::class)
->convertQueryToDoctrineQueryBuilder($query);
$doctrineSql = $doctrineObj->getSQL();
$params = $doctrineObj->getParameters();
$search = $replace = [];
foreach ($params as $k => $v) {
$search[] = ':' . $k;
$replace[] = '\'' . $v . '\'';
}
krsort($search);
krsort($replace);
$sql = str_replace($search, $replace, $doctrineSql);
echo($sql . '<hr>');
echo($doctrineSql . '<hr>');
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment