You are here

function google_analytics_reports_plugin_query_google_analytics::add_where in Google Analytics Reports 7.3

Add a filter string to the query.

Parameters

$group: The filter group to add these to; groups are used to create AND/OR sections of the Google Analytics query. Groups cannot be nested. Use 0 as the default group. If the group does not yet exist it will be created as an AND group.

$field: The name of the metric/dimension/field to check.

$value: The value to test the field against. In most cases, this is a scalar.

$operator: The comparison operator, such as =, <, or >=.

File

plugins/google_analytics_reports_plugin_query_google_analytics.inc, line 99
Defines the default query object which builds queries for the Google Analytics Reports API.

Class

google_analytics_reports_plugin_query_google_analytics
Object used to create a Google Analytics Core Reporting API query.

Code

function add_where($group, $field, $value = NULL, $operator = NULL) {

  // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
  // the default group.
  if (empty($group)) {
    $group = 0;
  }

  // Check for a group.
  if (!isset($this->where[$group])) {
    $this
      ->set_where_group('AND', $group);
  }
  $this->where[$group]['conditions'][] = array(
    'field' => $field,
    'value' => $value,
    'operator' => $operator,
  );
}