I am constructing a query that has to fetch the field collection line item, and it's associated field collection field to get the node id that the field collection field is being used on. The problem is it's only ever returning one single result when I know for sure there are at least two to return. Perhaps a fresh set of eyes can help.
Run list field table
"entity_type","bundle","deleted","entity_id","revision_id","language","delta","field_run_list_item_value","field_run_list_item_revision_id"
"node","run_list",0,100000018,48,"und",0,4,12
"node","run_list",0,100000017,47,"und",1,3,11
"node","run_list",0,100000017,47,"und",0,2,10
Run List field's line item table:
"entity_type","bundle","deleted","entity_id","revision_id","language","delta","field_story_target_id"
"field_collection_item","field_run_list_item",0,2,10,"und",0,100000004
"field_collection_item","field_run_list_item",0,3,11,"und",0,100000009
"field_collection_item","field_run_list_item",0,4,12,"und",0,100000004
This is my query:
$rl_query = db_select('field_data_field_story', 'fci');
$rl_query->fields('fci', array('field_story_target_id', 'bundle', 'entity_id'));
$rl_query->leftJoin('field_revision_field_run_list_item', 'rl', 'rl.field_run_list_item_value = fci.entity_id');
$rl_query->fields('rl', array('entity_id', 'field_run_list_item_value'));
$rl_query->condition('fci.field_story_target_id', $node->nid);
$rl_results = $rl_query->execute()->fetchAll;
When I dpm($rl_results);
it ends up looking like:
... (Array, 1 element)
0 (Object) stdClass
field_story_target_id (String, 9 characters ) 100000004
bundle (String, 19 characters ) field_run_list_item
entity_id (String, 1 characters ) 2
rl_entity_id (String, 9 characters ) 100000017
field_run_list_item_value (String, 1 characters ) 2
I should expect to see more than one result returned. In this example, there should be two.