FetchObject() only return one result Select query will always return a result set object of one record.. There are several ways to then retrieve data from that result set, depending on the use case. 

   user's flaged entity id:

  $query = db_select('flagging', 'f');
  $query-&gt;condition('f.uid', $data['uid'], '=');
  $query-&gt;fields('f', array('entity_id'));
  $result = $query-&gt;execute()-&gt;fetchObject();


and also used following query statements 

         $query-&gt;__toString()

         SELECT f.entity_id AS entity_id  FROM {flagging} f WHERE  (f.uid = :db_condition_placeholder_0) 


I replace the db_condition_placeholder_0  with specify uid.
It return me the right result (2 results).

   **$query-&gt;execute()-&gt;fetchAssoc()**`, 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;