Skip to content

Instantly share code, notes, and snippets.

@cbeier
Last active October 15, 2015 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbeier/f331eeb3a99db1c35646 to your computer and use it in GitHub Desktop.
Save cbeier/f331eeb3a99db1c35646 to your computer and use it in GitHub Desktop.
Drupal 7: Debug Query
<?php
function debug_query($query) {
$querystring = $query->__toString();
$querystring = str_replace("{", '', $querystring);
$querystring = str_replace("}", '', $querystring);
foreach ($query->getArguments() as $key => $item) {
if (!$item) {
$item = 'NULL';
}
$querystring = str_replace($key. ')', $item . ')', $querystring);
}
$tags = isset($query->alterTags) ? $query->alterTags : array();
$debug = array(
'query' => $querystring,
'tags' => $tags,
);
dpm($debug);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment