db_affected_rows in Drupal 7 for db_query
That information is directly returned by the execute() method of Delete/UpdateQuery, see for example: UpdateQuery::execute().

&lt;?php
$affected = db_update('some_table')
  -&gt;fields(array(
    'some_field' =&gt; $value,
  ))
  -&gt;condition('another_field', $id)
  -&gt;execute();
?&gt;


And InsertQuery::execute() returns the last insert id.