Skip to content

Instantly share code, notes, and snippets.

@rodmcnew
Last active August 29, 2015 14:05
Show Gist options
  • Save rodmcnew/3133bce70c2f5f606957 to your computer and use it in GitHub Desktop.
Save rodmcnew/3133bce70c2f5f606957 to your computer and use it in GitHub Desktop.
Easily see what queries doctrine is running for a page load
<?php
/**
* Inside doctrine locate the executeQuery() method inside the \Doctrine\DBAL\Connection class.
* ADD THE FOLLOWING TO THE BEGINNING OF THE executeQuery() METHOD:
*/
/**
* ADDED TO PROFILE QUERIES
*/
if (!isset($GLOBALS['queryCount'])) {
$GLOBALS['queryCount'] = 0;
}
$GLOBALS['queryCount']++;
var_dump($GLOBALS['queryCount'], $query, $params);
echo('<hr>');
if ($qcp !== null) {
return $this->executeCacheQuery($query, $params, $types, $qcp);
}
/**
* END ADDED TO PROFILE QUERIES
*/
/**
* Output in the browser will look like:
* int 31
* string 'SELECT r0_.defaultText AS defaultText0, r0_.text AS text1 FROM rcmi18n_message r0_ WHERE r0_.locale = ?' (length=103)
* array (size=1)
* 0 => string 'en_US' (length=5)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment