How to pass a db_query as an array instead of a string?
There are three errors in that query:


The database tables are not field_config_instance(), and field_config(), but field_config_instance, and field_config. Parentheses have a particular meaning in SQL, and putting them after a table name causes an error message.
The field_config_instance table doesn't contain any "label" field. See the schema definition given in field_schema().

$schema['field_config_instance'] = array(
  'fields' =&gt; array(
    'id' =&gt; array(
      'type' =&gt; 'serial', 
      'not null' =&gt; TRUE, 
      'description' =&gt; 'The primary identifier for a field instance',
    ), 
    'field_id' =&gt; array(
      'type' =&gt; 'int', 
      'not null' =&gt; TRUE, 
      'description' =&gt; 'The identifier of the field attached by this instance',
    ), 
    'field_name' =&gt; array(
      'type' =&gt; 'varchar', 
      'length' =&gt; 32, 
      'not null' =&gt; TRUE, 
      'default' =&gt; '',
    ), 
    'entity_type' =&gt; array(
      'type' =&gt; 'varchar', 
      'length' =&gt; 32, 
      'not null' =&gt; TRUE, 
      'default' =&gt; '',
    ), 
    'bundle' =&gt; array(
      'type' =&gt; 'varchar', 
      'length' =&gt; 128, 
      'not null' =&gt; TRUE, 
      'default' =&gt; '',
    ), 
    'data' =&gt; array(
      'type' =&gt; 'blob', 
      'size' =&gt; 'big', 
      'not null' =&gt; TRUE, 
      'serialize' =&gt; TRUE,
    ), 
    'deleted' =&gt; array(
      'type' =&gt; 'int', 
      'size' =&gt; 'tiny', 
      'not null' =&gt; TRUE, 
      'default' =&gt; 0,
    ),
  ), 
  'primary key' =&gt; array('id'), 
  'indexes' =&gt; array(
    // Used by field_delete_instance().
    'field_name_bundle' =&gt; array('field_name', 'entity_type', 'bundle'),
    // Used by field_read_instances(). 
    'deleted' =&gt; array('deleted'),
  ),
);

Drupal 7 placeholders aren't wrapped between quotes, when they are for strings.


The following query should not return any error.

SELECT nfi.field_name FROM {field_config_instance} nfi
  INNER JOIN {field_config} nf ON nfi.field_name = nf.field_name
  WHERE nfi.type_name = :type_name  AND nf.active = 1 AND nf.locked = 0