Skip to content

Instantly share code, notes, and snippets.

@chriwo
Created July 31, 2017 07:35
Show Gist options
  • Save chriwo/b6c035af97016aa0af123b0bdb8d4274 to your computer and use it in GitHub Desktop.
Save chriwo/b6c035af97016aa0af123b0bdb8d4274 to your computer and use it in GitHub Desktop.
TYPO3 Query debug function
/**
* Debugs a SQL query from a QueryResult
*
* @param QueryResult $queryResult
* @param boolean $explainOutput
* @return void
*/
public function debugQuery(QueryResult $queryResult, $explainOutput = false)
{
$GLOBALS['TYPO3_DB']->debugOuput = 2;
if ($explainOutput) {
$GLOBALS['TYPO3_DB']->explainOutput = true;
}
$GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true;
$queryResult->toArray();
DebuggerUtility::var_dump($GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
$GLOBALS['TYPO3_DB']->store_lastBuiltQuery = false;
$GLOBALS['TYPO3_DB']->explainOutput = false;
$GLOBALS['TYPO3_DB']->debugOuput = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment