In a the hook
hook_view_query_alter, i need to arrange the query to put some result at the very first, with some complexes conditions.
To that, in mysql, we can use the "if" function in the select part of the query and then add a "order by" on this field, for exemple like this :
select id, if(col_A > x and (colB < y);1;0) as first from my_table order_by first
I need to apply that to the query of my view.
On a regular dynamic Drupal query, we can use the
addExpression function where we can put anything.
I can't found a equivalent for the views\query\Sql class. I tried :
$query->addField( 'pm', "pm.field_tags_make_target_id is not null or(activity_field_data.user_id = ".$user->id()." and activity_field_data.created > ".$timeStamp.") ,1,0", "is_first",['function'=>"if"]);
but it seem to be ignored when it build the query.
So how to had customised expression in the "select" part of view query?