You are here

public function DatabaseDataCollector::getData in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/DatabaseDataCollector.php \Drupal\webprofiler\DataCollector\DatabaseDataCollector::getData()
  2. 8 webprofiler/src/DataCollector/DatabaseDataCollector.php \Drupal\webprofiler\DataCollector\DatabaseDataCollector::getData()
  3. 8.2 webprofiler/src/DataCollector/DatabaseDataCollector.php \Drupal\webprofiler\DataCollector\DatabaseDataCollector::getData()

Return value

mixed

Overrides DrupalDataCollectorInterface::getData

File

webprofiler/src/DataCollector/DatabaseDataCollector.php, line 203

Class

DatabaseDataCollector
Class DatabaseDataCollector.

Namespace

Drupal\webprofiler\DataCollector

Code

public function getData() {
  $data = $this->data;
  $conn = Database::getConnection();
  foreach ($data['queries'] as &$query) {
    $explain = TRUE;
    $type = 'select';
    if (strpos($query['query'], 'INSERT') !== FALSE) {
      $explain = FALSE;
      $type = 'insert';
    }
    if (strpos($query['query'], 'UPDATE') !== FALSE) {
      $explain = FALSE;
      $type = 'update';
    }
    if (strpos($query['query'], 'CREATE') !== FALSE) {
      $explain = FALSE;
      $type = 'create';
    }
    if (strpos($query['query'], 'DELETE') !== FALSE) {
      $explain = FALSE;
      $type = 'delete';
    }
    $query['explain'] = $explain;
    $query['type'] = $type;
    $quoted = [];
    if (isset($query['args'])) {
      foreach ((array) $query['args'] as $key => $val) {
        $quoted[$key] = is_null($val) ? 'NULL' : $conn
          ->quote($val);
      }
    }
    $query['query_args'] = strtr($query['query'], $quoted);
  }
  $data['query_highlight_threshold'] = $this
    ->getQueryHighlightThreshold();
  return $data;
}