How do you view the query that a 'View' is using to gather data from the database?
2 Answers
Go to admin/structure/views/settings
, check Show information and statistics about the view during live preview
and then Show the SQL query
checkbox that will appear below.
If you want to see a preview of the query being used when viewing the view as opposed to editing it you can use hook_views_pre_execute()
:
function MYMODULE_views_pre_execute(&$view) {
dpq($view->build_info['query']);
}
The dpq()
function is provided by the devel module so you will need to have that installed for this to work.