function 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,
    ]);
}