Alter views with hook_views_query_alter() i'm trying to hook all my site views with hook_views_query_alter()

I can't find how to add a relationship and condition in the query. 

Here is my (not working) code

/**
 * Implementation of hook_views_api().
 */
function taxonomy_location_views_api() { // your module name into hook_views_api
  return array(
    'api' =&gt; 2,
    'path' =&gt; drupal_get_path('module', 'taxonomy_location'),
  );
}

/**
 * Implementation of hook_views_query_alter().
 */
function taxonomy_location_views_query_alter(&amp;$view, &amp;$query) {
  // get taxonomy term ID
  $tid = subdomain_get_sid(subdomain_get_current_subdomain());
  if($tid) {
    $join = new views_join;
    $join-&gt;construct('term_node', 'node', 'nid', 'nid', array(), 'INNER');
    $query-&gt;add_relationship('term_node', $join, 'node');
    $query-&gt;add_where('term_node', 'term_node.tid', $tid);
  }
}


Any ideas?
I found a slightly different solution that works.

Instead of adding programatically the relation, I instead added a clause in $query-&gt;where

function taxonomy_location_views_query_alter(&amp;$view, &amp;$query) {
  $tid = subdomain_get_sid(subdomain_get_current_subdomain());
  if($tid) {
    $query-&gt;where[0]['clauses'][] = "(node.vid IN (SELECT tn.vid FROM term_node tn WHERE tn.tid = %d))";
    $query-&gt;where[0]['args'][] = $tid;
  }
}