How to convert a D7 db_query object to string? I am trying to perform the following:

$office_ids = db_query('SELECT OFFICE_ID FROM sage.OFFICE');
foreach($office_ids as $office) {
  ...
  $path = 'office-' . (string)$office;
}


However, I am getting the following error:

Recoverable fatal error: Object of class stdClass could not be converted to string in main() (line 31 of /var/www/drupal7/create_nodes_office.php).


How can I cast an object returned by 'db_query' into a string?

Thanks.
I can't see any benefit to doing that, are you sure you're not trying to get the OFFICE_ID value like this?:

$office_ids = db_query('SELECT OFFICE_ID FROM sage.OFFICE');
foreach($office_ids as $office) {
  ...
  // Depending on your database settings this might actually be lower case, i.e. $office-&gt;office_id
  $path = 'office-' . $office-&gt;OFFICE_ID;
}