No puedes encadenar leftJoin
(o cualquier join
) en las consultas de Drupal, porque leftJoin()
devuelve el alias, no la consulta. Entonces deberías usar execute()
para "ejecutar" la consulta.
$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()) {
//..
}
Tienes que agregar campos:
$query = db_select('node', 'n')->fields('n');
o
$query = db_select('node', 'n')
->addField('n','title')
->addField('n','nid');