2

One of drupal view displays reviews based on a selected event. It should display 3 reviews but instead it displays only 2. It doesn't happen for all the events and only for certain events instead of 3 it displays 2 items. As the data is all correct and I have validated the same. I wanted to see the query that is being used. The query that is displayed in the view is not helping me either. If I copy paste the same and run the sql, it throws a lot of error. How can I debug and see what is the query that got executed for that particular view? The view has relationsships and also it uses contextual filters. Thanks

  • What errors you are referring to when you execute the query given by the Views UI? If you post a sample of a query, someone could probably explain. – cilefen May 7 '16 at 0:48
4

The query displayed in the administration UI contains database prefixing brackets. You can remove those brackets to have valid SQL that can be executed by any SQL client.

  • Yes I tried removing those {} brackets but still its not working.There are few lines like 'field_collection_item' AS field_data_field_art_id_field_collection_item_entity_type, 'node' AS field_data_field_magazine_published_date_node_entity_type, 'node' AS field_data_field_book_review_synopsis_node_entity_type. How does sql interprets it? – Srividhya May 9 '16 at 16:27
  • Aliasing ("column AS alias") is valid SQL syntax. Without knowing the SQL client error, it's hard to know what it doesn't like about the query. – Shawn Conn May 10 '16 at 3:43
2

The Devel module has a setting that will show all executed queries in the footer.

  • 1
    Yeah, but it keeps the data placeholders. I want to actually see the real query. – Francisco Corrales Morales Mar 8 '17 at 20:00
0

You have to use hook_views_pre_execute and with Devel installed use dpq to view the SQL String:

function hook_views_pre_execute(&$view) {
  dpq($view->build_info['query']);
}

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.