U kunt leftJoin
niet koppelen (of een join
) in Drupal-query's, omdat leftJoin()
retourneert de alias, niet de query. Gebruik dan execute()
om de query te "uitvoeren".
$or = db_or()
->condition('fd.field_detailed_question_value', '%'.db_like($term ).'%', 'LIKE')
->condition('fb.body_value','%'.db_like($term ).'%' , 'LIKE');
$query = db_select('node', 'n');
$query->fields('n');
$query->leftJoin('field_data_body' , 'fb', 'fb.entity_id=n.nid');
$query->leftJoin('field_data_field_detailed_question' ,'fd', 'fd.entity_id=n.nid');
$query->condition($or);
$stmt = $query->execute(); // execute the query (returns the "statement" to fetch).
while ($row = $stmt->fetchObject()) {
//..
}
U moet velden toevoegen:
$query = db_select('node', 'n')->fields('n');
of
$query = db_select('node', 'n')
->addField('n','title')
->addField('n','nid');