Last active
February 24, 2022 10:47
-
-
Save fchaussin/449d878607f28746d8e8485e74a5dbd0 to your computer and use it in GitHub Desktop.
Debug SQL Queries in TYPO3 Repository (Extbase)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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