You are here

public function views_xml_backend_plugin_query_xml::query in Views XML Backend 7

Same name and namespace in other branches
  1. 6 views_xml_backend_plugin_query_xml.inc \views_xml_backend_plugin_query_xml::query()

Generates a query and a countquery from all of the information supplied to the object.

Parameters

bool $get_count: (Optional) Provide a countquery if this is true, otherwise provide a normal query. Defaults to FALSE.

Overrides views_plugin_query::query

1 call to views_xml_backend_plugin_query_xml::query()
views_xml_backend_plugin_query_xml::build in ./views_xml_backend_plugin_query_xml.inc
Builds the necessary info to execute the query.

File

./views_xml_backend_plugin_query_xml.inc, line 32
Contains views_xml_backend_plugin_query_xml.

Class

views_xml_backend_plugin_query_xml
@file Contains views_xml_backend_plugin_query_xml.

Code

public function query($get_count = FALSE) {
  $row_xpath = $this->options['row_xpath'];
  if ($this->filter) {
    $filters = array();
    foreach ($this->filter as $group_id => $group) {

      // $group is an array of views_xml_backend_handler_filter()'s. They
      // implement __toString(), so imploding calls their generate() method.
      if (count($group) == 1) {
        $filters[] = reset($group);
      }
      else {

        // Type could be 'AND' or 'OR'.
        $op = strtolower($this->where[$group_id]['type']);
        $filters[] = '(' . implode(" {$op} ", $group) . ')';
      }
    }
    $op = strtolower($this->group_operator);
    $row_xpath .= '[' . implode(" {$op} ", $filters) . ']';
  }
  if ($this->argument) {
    $row_xpath .= '[' . implode(' and ', $this->argument) . ']';
  }
  return $row_xpath;
}