You are here

public function ViewExecutable::startQueryCapture in Views (for Drupal 7) 8.3

Set up query capturing.

db_query() stores the queries that it runs in global $queries, bit only if dev_query is set to true. In this case, we want to temporarily override that setting if it's not and we can do that without forcing a db rewrite by just manipulating $conf. This is kind of evil but it works.

1 call to ViewExecutable::startQueryCapture()
ViewExecutable::render in lib/Drupal/views/ViewExecutable.php
Render this view for a certain display.

File

lib/Drupal/views/ViewExecutable.php, line 1750
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function startQueryCapture() {
  global $conf, $queries;
  if (empty($conf['dev_query'])) {
    $this->fix_dev_query = TRUE;
    $conf['dev_query'] = TRUE;
  }

  // Record the last query key used; anything already run isn't
  // a query that we are interested in.
  $this->last_query_key = NULL;
  if (!empty($queries)) {
    $keys = array_keys($queries);
    $this->last_query_key = array_pop($keys);
  }
}