$arPlan = $rsData->Fetch(); } } else { $rsData = false; } } else { $rsData = false; } if ($rsData) { $SQL_TEXT = CPerfomanceSQL::Format($strSQL); $lAdmin->BeginPrologContent(); if (class_exists("geshi")) { $obGeSHi = new GeSHi(CSqlFormat::reformatSql($SQL_TEXT), 'sql'); echo $obGeSHi->parse_code(); } else { echo "<p>" . str_replace(array(" ", "\t", "\n"), array(" ", " ", "<br>"), htmlspecialcharsbx(CSqlFormat::reformatSql($SQL_TEXT))) . "</p>"; } if ($arPlan["OPTIMIZER"]) { echo "<p>" . GetMessage("PERFMON_EXPLAIN_F_OPTIMIZER") . ": " . $arPlan["OPTIMIZER"] . "</p>"; echo "<p>" . GetMessage("PERFMON_EXPLAIN_F_COST") . ": " . $arPlan["POSITION"] . "</p>"; } $lAdmin->EndPrologContent(); } else { $rsData = new CDBResult(); $rsData->InitFromArray(array()); $lAdmin->BeginPrologContent(); $message = new CAdminMessage(array("MESSAGE" => GetMessage("PERFMON_EXPLAIN_SQL_ERROR"), "TYPE" => "ERROR")); echo $message->Show(); $lAdmin->EndPrologContent(); } $Comment = "";
if ($_REQUEST["mode"] == "excel") $row->AddViewField("QUERY_TIME", number_format($f_QUERY_TIME, 6, ".", "")); else $row->AddViewField("QUERY_TIME", str_replace(" ", " ", number_format($f_QUERY_TIME, 6, ".", " "))); if (class_exists("geshi") && $f_SQL_TEXT) { $obGeSHi = new GeSHi(CSqlFormat::reformatSql($arRes["SQL_TEXT"], new CSqlFormatText), 'sql'); $html = $obGeSHi->parse_code(); } else { $html = str_replace( array(" ", "\t", "\n"), array(" ", " ", "<br>"), htmlspecialcharsbx(CSqlFormat::reformatSql($arRes["SQL_TEXT"])) ); } $html = '<span onmouseover="addTimer(this)" onmouseout="removeTimer(this)" id="'.$f_ID.'_sql_backtrace">'.$html.'</span>'; $row->AddViewField("SQL_TEXT", $html); $row->AddViewField("HIT_ID", '<a href="perfmon_hit_list.php?lang='.LANGUAGE_ID.'&set_filter=Y&find_id='.$f_HIT_ID.'">'.$f_HIT_ID.'</a>'); if ($bCluster && $arRes["NODE_ID"] != "") $row->AddViewField("NODE_ID", $arRes["NODE_ID"] > 1? $arClusterNodes[$arRes["NODE_ID"]]: $arClusterNodes[1]); $arActions = array(); if ($DBType == "mysql" || $DBType == "oracle") { $arActions[] = array( "DEFAULT" => "Y",
public static function reformatSql($sql, CSqlFormatFormatter $formatter = null) { if (function_exists('token_get_all')) { $format = new CSqlFormat(); $format->setFormatter($formatter ? $formatter : new CSqlFormatText()); return $format->format($sql); } else { return $sql; } }
$arSelectedFields = array("ID", "HIT_ID", "NN", "QUERY_TIME", "SQL_TEXT"); } $cData = new CPerfomanceSQL(); $rsData = $cData->GetList($arSelectedFields, $arFilter, array($by => $order), false, array("nPageSize" => CAdminResult::GetNavSize($sTableID))); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart(); $lAdmin->NavText($rsData->GetNavPrint(GetMessage("PERFMON_SQL_PAGE"))); while ($arRes = $rsData->NavNext(true, "f_")) { $arRes["SQL_TEXT"] = CPerfomanceSQL::Format($arRes["SQL_TEXT"]); $row =& $lAdmin->AddRow($f_NAME, $arRes); $row->AddViewField("QUERY_TIME", perfmon_NumberFormat($f_QUERY_TIME, 6)); if (class_exists("geshi") && $f_SQL_TEXT) { $obGeSHi = new GeSHi(CSqlFormat::reformatSql($arRes["SQL_TEXT"], new CSqlFormatText()), 'sql'); $html = $obGeSHi->parse_code(); } else { $html = str_replace(array(" ", "\t", "\n"), array(" ", " ", "<br>"), htmlspecialcharsbx(CSqlFormat::reformatSql($arRes["SQL_TEXT"]))); } $html = '<span onmouseover="addTimer(this)" onmouseout="removeTimer(this)" id="' . $f_ID . '_sql_backtrace">' . $html . '</span>'; $row->AddViewField("SQL_TEXT", $html); $row->AddViewField("HIT_ID", '<a href="perfmon_hit_list.php?lang=' . LANGUAGE_ID . '&set_filter=Y&find_id=' . $f_HIT_ID . '">' . $f_HIT_ID . '</a>'); if ($bCluster && $arRes["NODE_ID"] != "") { $row->AddViewField("NODE_ID", $arRes["NODE_ID"] > 1 ? $arClusterNodes[$arRes["NODE_ID"]] : $arClusterNodes[1]); } $arActions = array(); if ($DBType == "mysql" || $DBType == "oracle") { $arActions[] = array("DEFAULT" => "Y", "TEXT" => GetMessage("PERFMON_SQL_EXPLAIN"), "ACTION" => 'jsUtils.OpenWindow(\'perfmon_explain.php?lang=' . LANG . '&ID=' . $f_ID . '\', 600, 500);'); } if (count($arActions)) { $row->AddActions($arActions); } }