I want to print the query which is built using db_select() in a programmatical way. Is there any API function provided by Drupal Abstraction Layer?
It is similar to query output in Views, but I want to print it from my custom module for debugging purpose.
|
|||
|
Consider the following code.
Its output is the following one.
To get the array of arguments used for the query, you can call SelectQuery::arguments(). The following code returns the query, and its arguments. It requires the Devel module.
Notice that You could use a function similar to the following one to get the string query, with the placeholders replaced with the arguments.
|
||||
|
You can use dpq() to display the query, and dpr() to display the result.
|
||||
|