Exemplo n.º 1
0
            $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(" ", "&nbsp;&nbsp;&nbsp;", "<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 = "";
Exemplo n.º 2
0
	if ($_REQUEST["mode"] == "excel")
		$row->AddViewField("QUERY_TIME", number_format($f_QUERY_TIME, 6, ".", ""));
	else
		$row->AddViewField("QUERY_TIME", str_replace(" ", "&nbsp;", 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(" ", "&nbsp;&nbsp;&nbsp;", "<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.'&amp;set_filter=Y&amp;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",
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
    $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(" ", "&nbsp;&nbsp;&nbsp;", "<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 . '&amp;set_filter=Y&amp;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);
    }
}