Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created October 31, 2012 08:20
Show Gist options
  • Select an option

  • Save junaidpv/3985830 to your computer and use it in GitHub Desktop.

Select an option

Save junaidpv/3985830 to your computer and use it in GitHub Desktop.
View the query executed by the view in Drupal 7
diff --git a/sites/all/modules/views/plugins/views_plugin_query_default.inc b/sites/all/modules/views/plugins/views_plugin_query_default.inc
index 39e8061..1a34443 100644
--- a/sites/all/modules/views/plugins/views_plugin_query_default.inc
+++ b/sites/all/modules/views/plugins/views_plugin_query_default.inc
@@ -1393,6 +1393,19 @@ class views_plugin_query_default extends views_plugin_query {
$query->range($offset, $limit);
}
+ $query_string = (string)$query;
+ $query_string = str_replace('{', '', $query_string);
+ $query_string = str_replace('}', '', $query_string);
+ $query_params = $query->getArguments();
+ foreach($query_params as $placeholder => $value) {
+ if(!is_numeric($value)) {
+ $query_string = str_replace($placeholder, "'$value'", $query_string);
+ }
+ else {
+ $query_string = str_replace($placeholder, $value, $query_string);
+ }
+ }
+ drupal_set_message($query_string);
$result = $query->execute();
$view->result = array();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment