What is the best way to do a db query for fields in a content type?
I need to get specific fields from a content type, but only where the 'featured' field value is 1.
<?php
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'mycontenttype')
->propertyCondition('status', NODE_PUBLISHED)
->fieldCondition('field_mypdf', 'value', 'NULL', '!=')
->fieldCondition('field_mypdf', 'fid', 'NULL', '!=')
->fieldCondition('field_mypdf_image', 'fid', 'NULL', '!=')
?>
Originally, I was doing something along the lines of:
<?php
$query = "SELECT node.nid AS nid, 'node' AS field_data_field_news_node_entity_type, 'node' AS field_data_field_news_date_text_node_entity_type, 'node' AS field_data_field_news_teaser_node_entity_type, 'node' AS field_data_field_news_body_node_entity_type, 'node' AS field_data_field_news_video_node_entity_type, 'node' AS field_data_field_news_video_image_node_entity_type, 'node' AS field_data_field_mypdf_node_entity_type
FROM node
INNER JOIN field_data_field_news_is_featured ON node.nid = field_data_field_news_is_featured.entity_id AND (field_data_field_news_is_featured.entity_type = 'node' AND field_data_field_news_is_featured.deleted = '0')";
?>
$result = db_query($query);
<?php foreach ($result as $row) : ?>
<div class="featuredArticle">
<?php print $row->field_mypdf_value; ?>
<?php print $row->field_mypdf_fid; ?>
</div>
<?php endforeach; ?>