0

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(&$view, &$query) {
    if ($view->name == 'search_jobs'){

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

Has anyone experienced this issue before?

3

If you want show sql query you can use code below:

function example_views_pre_execute(&$view) {
  if ($view->name == 'search_jobs'){
        dpq($view->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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.