I'm using hook_views_query_alter(), and I'd really like to print somewhere (screen, error log, whatever) the query that's being run based on the alterations. I've tried dpm($query), but that gives me the whole krumo tree - all I want is the query - i.e. "select x, y from z where a = 2". Possible?
SelectQuery class implements the magic
__toString() method you can then cast it directly to a string, which will be the SQL query itself:
$select_query = $query->query(); $query_string = (string)$select_query; dpm($query_string);