Reply to comment

Viewing the sql generated from a view

Yes, super simple, but it did take me a good 15 minutes to figure out how.
In my mymodule_views_query_alter(&$view, &$query) function, I had access to the $query variable.  Doing a print and print_r of the query object provided a object view of the query, but NOT the underlying SQL
I dug into the views module and discovered the Query class (in views/include) and it described a "query" function that built up the sql string.
 
Hence, this worked for me (it output the sql that the view would generate):
 
print($query -> query(false));

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options