0

I have a problem with db_select, i want to return a node per row for each value of the multiple values field :

  • node_1 : value_1_of_the_multiple_values_field
  • node_1 : value_2_of_the_multiple_values_field
  • node_1 : value_2_of_the_multiple_values_field
  • ...

here is my code with the join it only return a node linked to the values of the field :

$query = db_select('node', 'n')
->extend('PagerDefault');

// Add join with multiple values field ( a date )

$query->join('field_data_field_date_programme_culturel', 'fdfdpc', 'fdfdpc.entity_id = n.nid');
$query->fields('n');

any idea please?

1 Answer 1

0

I've often struggled with the join methods in the D7 database layer. When I've needed to use a join, I've just used db_query() and passed it my SQL string. I know that when calling the join() method, you must already have the object initialised. So:

$query = db_select('node', 'n');
$query->join(field_data_field_date_programme_culturel', 'fdfdpc', 'fdfdpc.entity_id = n.nid');

and you already have it like this so I don't think that's the issue. I'd suggest using db_query($sql).

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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