I was stucked making a few tweaks to a view trying to do the following. In mysql exists the possibility to use WHERE IF to evaluate some variable/operation to apply differents conditions depending on the result/value, like a common IF/ELSE block, is there any way to do it with add_where() or any other similar method? I need to apply a WHERE condition to the query when the value of a variable called $scope is G and a different when its L, there's any way to achieve that?
What I need to do is to do this query on Drupal 7 Views hooks
SELECT * FROM tbl1 AS t1 JOIN tbl2 AS t2 ON t2.entity_id = t1.nid JOIN tbl3 AS t3 ON t3.entity_id = t1.uid WHERE t1.status = 1 AND t1.type = "article" AND IF(t2.field_alcance_nodo_value = '{char}', t3.field_pais_usuario_value = '{string}', t3.field_pais_usuario_value LIKE '%') ORDER BY t1.changed DESC;
but I'm stucked on the IF part... I'm using the hook_views_query_alter() but I don't know if it's enough.
Thank you in advance,