I am trying to add a condition to a query like:
civicrm_contact_civicrm_relationship.id <> civicrm_contact_civicrm_relationship_1.id
but for the second field drupal takes it as a string so it always result into
civicrm_contact_civicrm_relationship.id <> 'civicrm_contact_civicrm_relationship_1.id'
I've tried to play with the numerical value with no success.
Any idea how can I do this? May be with another hook? any tip will be welcome!
My code:
$view->query->where[2]["conditions"][0]["field"] = "civicrm_contact_civicrm_relationship_1.id";
$view->query->where[2]["conditions"][0]["operator"] = "IS NULL";
$view->query->where[2]["conditions"][0]["value"] = "";
$view->query->where[2]["conditions"][1]["field"] = "civicrm_contact_civicrm_relationship.id";
$view->query->where[2]["conditions"][1]["operator"] = "IS NULL";
$view->query->where[2]["conditions"][1]["value"] = "";
$view->query->where[2]["conditions"][2]["field"] = "civicrm_contact_civicrm_relationship.id";
$view->query->where[2]["conditions"][2]["value"] ="civicrm_contact_civicrm_relationship_1.id";
$view->query->where[2]["conditions"][2]["numeric"] = "1";
$view->query->where[2]["conditions"][2]["operator"] = "<>";
$view->query->where[2]["type"] = "OR";
try something like
function my_hook_views_query_alter(&$view, &$query) { if ($view->name == 'my_hook') { $alias = $query->add_table('civicrm_contact_civicrm_relationship','civicrm_contact_civicrm_relationship_1'); $query->add_where_expression(0,'civicrm_contact_civicrm_relationship.id <> civicrm_contact_civicrm_relationship_1.id'); dpm($query); //dumps object to admin with devel module } }