I want to display the query that is executed in the drupal view. Currently in the view editor it shows the query however I have a need to use that query in my code to download an excel version of the view.
Is there a way to get the executed query the same way it's shown in the "editor" window of the views menu? I want this at the time the the view is shown.
What I plan to do here is to capture the query in the footer, and have that query posted to a process which will send back an XLS resultset. So i'd like the exact query the view is using to display the results.
Or you can use hook_views_pre_execute
along with devel's dpq function:
function MY_MODULE_views_pre_execute(&$view) {
dpq($view->build_info['query']);
}