4

I'm trying to understand this Views SQL Query:

    SELECT node.nid AS nid, node.title AS node_title, 'node' AS 
field_data_field_icon_node_entity_type, 'node' AS 
field_data_field_price_node_entity_type, 'node' AS 
field_data_body_node_entity_type
    FROM 
    {node} node
    INNER JOIN {field_data_field_type} field_data_field_type ON node.nid = 
field_data_field_type.entity_id AND (field_data_field_type.entity_type = 
'node' AND field_data_field_type.deleted = '0')
    WHERE (( (node.status = '1') AND (node.type IN  ('resource')) AND 
(field_data_field_type.field_type_value = '4') ))
    ORDER BY node_title ASC
    LIMIT 10 OFFSET 0

Specifically, I need to know what the line in the SELECT statement that says 'node' AS field_data_field_icon_node_entity_type means.

I see in the database I have a field called 'field_data_field_icon' but not with the rest of the jargon attached to it. So I'm not sure how it's getting that data.

Anyone know?

5

The 'node' string is a placeholder of sorts.

Internally, it indicates to Views that we are not going to attempt to fetch the requested field value in this SQL query itself. Instead, during the Views render process, the full node object is going to be loaded, and the output for that Views field is going to come from partially rendering the node object.

This allows Views to take full advantage of Drupal's field formatting system, which would be impossible on raw SQL values.

  • Jim - thank you. That makes sense. This field is a taxonomy field with associated image so I suppose that's why it's doing that there. – Sage Oct 27 '15 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.