Created
August 3, 2013 08:35
-
-
Save grota/6145728 to your computer and use it in GitHub Desktop.
Debug Drupal EntityFieldQuery and Views Queries
This file contains 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
/** | |
* 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