You are here

function og_db_rewrite_sql in Organic groups 5

Same name and namespace in other branches
  1. 5.8 og.module \og_db_rewrite_sql()
  2. 5.2 og.module \og_db_rewrite_sql()
  3. 5.3 og.module \og_db_rewrite_sql()
  4. 5.7 og.module \og_db_rewrite_sql()

An implementation of hook_db_rewrite_sql(). Used by other modules to filter nodes to a given group

You must pass $args with element 'og_nid' => $nid in order to have your query filtered by this function

Return value

array

File

./og.module, line 2948

Code

function og_db_rewrite_sql($sql, $primary_table, $primary_field, $args) {
  if (isset($args['og_nid']) && is_numeric($args['og_nid'])) {
    $query['join'] = 'INNER JOIN {og_ancestry} oga ON n.nid = oga.nid';
    $query['where'] = 'oga.group_nid = ' . $args['og_nid'];
    return $query;
  }
}