Skip to content

Instantly share code, notes, and snippets.

@grota
Created August 3, 2013 08:35
Show Gist options
  • Save grota/6145728 to your computer and use it in GitHub Desktop.
Save grota/6145728 to your computer and use it in GitHub Desktop.
Debug Drupal EntityFieldQuery and Views Queries
/**
* Implements hook_query_alter
*/
function modulename_query_alter($query) {
if ($query->hasTag('debug') && module_exists('devel')) {
dpm(strtr((string) $query, $query->getArguments()));
}
}
/* When using an EntityFieldQuery */
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'serie')
->fieldCondition('og_group_ref', 'target_id', $country->nid)
->fieldCondition('og_vocabulary', 'target_id', 'NULL', '!=')
/* see hook_query_alter */
->addTag('debug');
/**
* Implements of hook_views_query_alter()
*/
function modulename_views_query_alter(&$view, &$query) {
$query->add_tag('debug');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment