For displaying query youYou can use dpq() functiondpq() to display the query, and dpr() to display printthe result dpr()
Example
$query = db_select('users','u'); $query->fields('u'); $query->condition('u.uid',1042); $result = $query->execute()->fetchAll();
dpq($query); // For Displaying Query dpr($result); // For Displaying Query results
$query = db_select('users','u');
$query->fields('u');
$query->condition('u.uid', 1042);
$result = $query->execute()->fetchAll();
dpq($query); // Display the query.
dpr($result); // Display the query result.