0

I created a test view. It displays data of a content type 'Anagrafiche (name for internal use: contatti)'. The view has the following fields (sorry for the interface language):

enter image description here

  • Contenuto: Immagine (Img) it's an image field
  • Contenuto: Nome (Name) it's a text field
  • Contenuto: Cognome (Surname) it's a text field

I used the proposed code for the following question, to get a 'clean' query: link

But the output was not what was expected:

SELECT
  node.nid AS nid,
  node.created AS node_created,
  node.changed AS node_changed,
  users_node.name AS users_node_name,
  users_node.uid AS users_node_uid,
  'node' AS field_data_field_immagine_node_entity_type,
  'node' AS field_data_field_nome_node_entity_type,
  'node' AS field_data_field_cognome_node_entity_type
FROM  node AS node
LEFT JOIN users AS users_node
  ON node.uid = users_node.uid
LEFT JOIN field_data_field_cognome AS field_data_field_cognome
  ON node.nid = field_data_field_cognome.entity_id
  AND (field_data_field_cognome.entity_type = 'node'
  AND field_data_field_cognome.deleted = 0)
WHERE (( (node.status = 1)
  AND (node.type IN  ('contatti')) ))
ORDER BY
  field_data_field_cognome.field_cognome_value ASC
LIMIT 20 OFFSET 0

I do not have very clear how the correct output should be, but by looking at the query, I gather that this piece is not correct

  'node' AS field_data_field_immagine_node_entity_type,
  'node' AS field_data_field_nome_node_entity_type,
  'node' AS field_data_field_cognome_node_entity_type

I also tried alternatives like the 'Devel' module and different types of hooks, but I never got what I wanted

@mikeytown2 I ran the query inside phpmyadmin this is the result: result

but the last three columns should not be node | node | node, but something like thatimg | myName | mySurname

  • 1
    Have you ran the query in something like MySQL? That query looks correct; it should match the views output. – mikeytown2 Oct 17 '18 at 7:58
  • @mikeytown2 updated question :) – Leo Oct 17 '18 at 8:37
1

I gather that this piece is not correct

It’s absolutely correct - Views is just using the query results to pass through some meta data about the operation.

In this case your view joins three different fields, and the types of entity that the fields are related to are nodes. Views is just keeping track of the that fact for each field, so it can use a generic processor for the results.

If you don’t need to use those fields from the query, you can safely ignore them.

  • I thank you for the answer. I'm not very practical, how could I make the fields process in order to read them correctly during the output of the query? – Leo Oct 16 '18 at 21:36

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.