title: Drupal 7 pull content type fields with db api
body: <p>What am I doing wrong. I can't seem to pull based upon content type fields in drupal 7.</p>
  
  <pre><code>function ycs_list($number) {
    $query = db_select('field_data_field_active_image', 'a')
    -&gt;fields('a', array('field_active_image_value', 'entity_id'))
    -&gt;condition('a.field_active_image_value', 1);
    $query-&gt;join('node', 'n', 'n.nid = a.entity_id');
    $query
    -&gt;fields('n', array('nid', 'title', 'uid'))
    -&gt;range(0, $number)
    -&gt;addTag('node_access')
    -&gt;execute();
    print $query;
    return $query;
  }
  </code></pre>
  
  <p>This is how the query prints:</p>
  
  <pre><code>SELECT a.field_active_image_value AS field_active_image_value, a.entity_id AS entity_id, n.nid AS nid, n.title AS title, n.uid AS uid FROM {field_data_field_active_image} a INNER JOIN {node} n ON n.nid = a.entity_id WHERE (a.field_active_image_value = :db_condition_placeholder_0) LIMIT 3 OFFSET 0
  </code></pre>
  
  <p>It looks right and does work directly in mysql. I have to change :db_conditon_placehoder_0 to 1 and it works doing a direct sql query. I want to pull an array of nodes based upon a condition in the active_image field. Any help would be much appreciated.</p>