public function actionExplain($tag, $num, $connection)
{
$this->loadData($tag);
$dbPanel = $this->getOwner()->panels['db'];
if (!$dbPanel instanceof Yii2DbPanel) {
throw new Exception('Yii2DbPanel not found');
}
if (!$dbPanel->canExplain) {
throw new CHttpException(403, 'Forbidden');
}
$message = $dbPanel->messageByNum($num);
if ($message === null) {
throw new Exception("Not found query by number {$num}");
}
$query = $dbPanel->formatSql($message, true);
/* @var CDbConnection $db */
$db = Yii::app()->getComponent($connection);
if (!Yii::app()->request->isAjaxRequest) {
$this->getOwner()->setLock($tag, true);
$this->render('explain', array('tag' => $tag, 'summary' => $this->summary, 'manifest' => $this->getManifest(), 'panels' => $this->getOwner()->panels, 'dbPanel' => $dbPanel, 'connection' => $db, 'procedure' => Yii2DbPanel::getExplainQuery($query, $db->driverName), 'explainRows' => Yii2DbPanel::explain($query, $db)));
} else {
$this->renderPartial('_explain', array('connection' => $db, 'explainRows' => Yii2DbPanel::explain($query, $db)));
}
}