* @since 2.0.6 */ class ExplainAction extends Action { /** * @var DbPanel */ public $panel; public function run($seq, $tag) { $this->controller->loadData($tag); $timings = $this->panel->calculateTimings(); if (!isset($timings[$seq])) { throw new HttpException(404, 'Log message not found.'); } $query = $timings[$seq]['info']; $results = $this->panel->getDb()->createCommand('EXPLAIN ' . $query)->queryAll(); $output[] = '' . implode(array_map(function($key) { return ''; }, array_keys($results[0]))) . ''; foreach ($results as $result) { $output[] = '' . implode(array_map(function($value) { return ''; }, $result)) . ''; } $output[] = '
' . $key . '
' . (empty($value) ? 'NULL' : htmlspecialchars($value)) . '
'; return implode($output); } }