FetchObject() only return one result
In Drupal 7, there are fetch methods that can help to avoid loops like that. From http://drupal.org/node/310072:

&lt;?php
  // Retrieve all records into an indexed array of stdClass bjects.
  $result-&gt;fetchAll();
 // Retrieve all records into an associative array keyed by the field in the result specified.
  $result-&gt;fetchAllAssoc($field);

  // Retrieve a 2-column result set as an associative array of field 1 =&gt; field 2.
  $result-&gt;fetchAllKeyed();
 // You can also specify which two fields to use by specifying the column numbers for each field
  $result-&gt;fetchAllKeyed(0,2); // would be field 0 =&gt; field 2
  $result-&gt;fetchAllKeyed(1,0); // would be field 1 =&gt; field 0

  // Retrieve a 1-column result set as one single array.
  $result-&gt;fetchCol();
  // Column number can be specified otherwise defaults to first column
  $result-&gt;fetchCol($column_index);
 ?&gt;