How to print the query which is built using db_select() in Drupal

Drupal is well known content management system is being used for all kind of websites. There is a good DB api to write queries in the custom modules. So if someone wants to print the actual sql query when using db_select?

Consider the following code

$query = db_select('node')
->condition('nid', 1)
->condition('status', 1)
print $query;
Editorial Staff

Editorial Staff at tutsplanet is a dedicated team to write various tutorial articles.