Debugging custom database queries Is there a convenient way to ask a particular database object to print its query?

Every now and then, I write a DBTNG db_op() in a module, and far to often, I don't quite get the queries right.

I know that devel can output the query log, but that's all queries, which, in this type of situation, is a problem more often than not.

I want to do

$result = db_select('node', 'n')-&gt;fields('n')-&gt;execute();
dpm($result-&gt;queryWithParameters);
dpm($result-&gt;finalQuery);
There is a dpq() function in the devel module which seems to fulfill this need.


  Print a SQL string from a DBTNG Query object. Includes quoted arguments.