Devel dpq() not working? I am trying to print the sql generated from the view but its not working. Below is the error message I am getting:-

Fatal error: Call to a member function arguments() on a non-object in /var/www/Exaxmple-Site/sites/all/modules/devel/devel.module on line 1834


I have seen many of them using this function to print the sql statement but in my case its giving error. Below is the code how I am calling the function.

function example_views_query_alter(&amp;$view, &amp;$query) {
    if ($view-&gt;name == 'search_jobs'){

        dpq($view-&gt;build_info['query']); 
    }
}


Has anyone experienced this issue before?
If you want show sql query you can use code below:

function example_views_pre_execute(&amp;$view) {
  if ($view-&gt;name == 'search_jobs'){
        dpq($view-&gt;build_info['query']); 
    }
}


In your code function dpq error because variable $view->build_info['query'] is NULL. The function dpq only run when variable is An object that implements the SelectQueryInterface interface.