You are here

public function DatabaseController::explainAction in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Controller/DatabaseController.php \Drupal\webprofiler\Controller\DatabaseController::explainAction()
  2. 8.2 webprofiler/src/Controller/DatabaseController.php \Drupal\webprofiler\Controller\DatabaseController::explainAction()
  3. 4.x webprofiler/src/Controller/DatabaseController.php \Drupal\webprofiler\Controller\DatabaseController::explainAction()

Parameters

Profile $profile:

int $qid:

Return value

JsonResponse

1 string reference to 'DatabaseController::explainAction'
webprofiler.routing.yml in webprofiler/webprofiler.routing.yml
webprofiler/webprofiler.routing.yml

File

webprofiler/src/Controller/DatabaseController.php, line 56

Class

DatabaseController
Class DatabaseController

Namespace

Drupal\webprofiler\Controller

Code

public function explainAction(Profile $profile, $qid) {
  $query = $this
    ->getQuery($profile, $qid);
  $data = [];
  $result = $this->database
    ->query('EXPLAIN ' . $query['query'], (array) $query['args'])
    ->fetchAllAssoc('table');
  $i = 1;
  foreach ($result as $row) {
    foreach ($row as $key => $value) {
      $data[$i][$key] = $value;
    }
    $i++;
  }
  return new JsonResponse([
    'data' => $data,
  ]);
}