I have to query my content types (firm_unit) based on different fields conditions, and for that I came to use EntityFieldQuery.
$query = new EntityFieldQuery;
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', $type = 'firm_unit')
->propertyCondition('status', 1);
This is nice when I want to query conditions on direct content fields, like these:
$query->fieldCondition('field_name', 'value', $keyword, 'CONTAINS');
$query->fieldCondition('field_sector', 'value', $sector, '=');
It seems to be unable to directly access, and then query by, referenced contents, like names/titles and fields of referenced terms (it just can access their tids).
Which is then the way I may query my node contents based on term referenced values?
Should I query the tid before (is the _taxonomy_get_tid_from_term func the proper to use?), and then query the content like this?
$my_tid = _taxonomy_get_tid_from_term ($term_to_match);<br/>
$query->fieldCondition('term_fieldname', 'tid', $my_tid);