Search code examples
drupaldrupal-6

Drupal: Return SQL string from db_query


Is it possible to return the actual SQL query as a string from the result of db_query?

Or otherwise take the returned resource ID from db_query and get the SQL string?


Edit:

As an addendum, I recently found out about db_queryd() from the Devel module, which echoes the query passed (as well as execute it). Doesn't return the string as this question asked, but really helpful for copying and pasting a complete query.


Solution

  • I don't think it is. However if you are only doing so for the purpose of debugging you can turn on the devel module and that will show you the queries run.

    Actually you could just set the variable 'dev_query' to 1 and then access the global array $queries, but I wouldn't recommend it.