1

I have content type picture which has a field with the machine name score. I have implemented the hook_views_query_alter() which looks like the following; the main part is that I add a line which adds an extra where condition:

function pic_anlysis_views_query_alter(&$view, &$query) 
{
    ...
    $query->where[1]['conditions'][2] = array('field'=>"node.score","value"=>array(30, 60),"operator"=>"BETWEEN");
}

But the above doesn't work; I think that node.score is the wrong key used to represent the field in the query. Anyone knows what I should use instead?

Thanks

James
  • 2,874
  • 4
  • 30
  • 55
user1888243
  • 2,591
  • 9
  • 32
  • 44

1 Answers1

2

Fields are not stored in node table.

Try

$query->add_where(1, 'field_data_field_score.value', array(30, 60), 'BETWEEN');
wikp
  • 1,123
  • 1
  • 8
  • 14
  • I think that's the solution, but further steps are necessary. Do I need to add the field_data_field_score as a relation to the view? I look at the database, and you are quite correct, but now the view completely fails. In the database, the following would be the table and column that store the information: field_data_field_score.field_score_value. – user1888243 Jun 09 '15 at 22:43