Anda tidak dapat merangkai leftJoin
(atau join
) dalam kueri Drupal, karena leftJoin()
mengembalikan alias, bukan kueri. Maka Anda harus menggunakan execute()
untuk "menjalankan" kueri.
$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()) {
//..
}
Anda harus menambahkan bidang :
$query = db_select('node', 'n')->fields('n');
atau
$query = db_select('node', 'n')
->addField('n','title')
->addField('n','nid');