How do I get a field count from an executed query?
Drupal uses PDO, whose equivalent function is PDOStatement::columnCount():


  Returns the number of columns in the result set represented by the PDOStatement object. If there is no result set, PDOStatement::columnCount() returns 0.


So what you're looking for isn't totally possible these days. I can't see a Drupal equivalent of columnCount(), but you can always grab the PDO connection object with Database::getConnection(), and work with that directly if it'll help you get part of the way there.

To take a different approach, and assuming you've used the schema API to describe your table to Drupal, you can query that instead:

$table = drupal_get_schema_unprocessed('MYMODULE', 'table_name');
$fields = $table['fields'];