コード例 #1
0
ファイル: descTable.php プロジェクト: qbdsoft/Query-Digest-UI
$desc = Database::find($label)->query_list_assoc('DESC ' . Database::escapeField($table));
$return['desc'] = '<table><thead><tr>';
foreach (array_keys($desc[0]) as $key) {
    $return['desc'] .= '<th>' . $key . '</th>';
}
$return['desc'] .= '</tr></thead><tbody>';
foreach ($desc as $row) {
    $return['desc'] .= '<tr>';
    foreach ($row as $key => $val) {
        $return['desc'] .= '<td>' . ifnull($val, 'NULL') . '</td>';
    }
    $return['desc'] .= '</tr>';
}
$return['desc'] .= '</tbody></table>';
unset($desc);
$indexes = Database::find($label)->query_list_assoc('SHOW INDEXES FROM ' . Database::escapeField($table));
$return['indexes'] = '<table><thead><tr>';
foreach (array_keys($indexes[0]) as $key) {
    $return['indexes'] .= '<th>' . $key . '</th>';
}
$return['indexes'] .= '</tr></thead><tbody>';
foreach ($indexes as $row) {
    $return['indexes'] .= '<tr>';
    foreach ($row as $key => $val) {
        $return['indexes'] .= '<td>' . ifnull($val, 'NULL') . '</td>';
    }
    $return['indexes'] .= '</tr>';
}
$return['indexes'] .= '</tbody></table>';
unset($indexes);
header('Cache-Control: no-cache, must-revalidate');
コード例 #2
0
ファイル: sample.php プロジェクト: qbdsoft/Query-Digest-UI
            $primaryKey .= ", {$field} ";
        }
    }
    $offset = 0;
    if (isset($_REQUEST['offset']) && $_REQUEST['offset'] > 0) {
        $offset = intval($_REQUEST['offset']);
    }
    $res = Database::find('review')->query('SELECT review.sample ' . $primaryKey . '
								  FROM ' . Database::escapeField($reviewhost['history_table']) . ' AS review
								 WHERE review.checksum = ?
							  ORDER BY review.ts_max DESC
							     LIMIT 1
								OFFSET ' . $offset, $_REQUEST['checksum']);
    $row = $res->fetch_assoc();
    $return['sample'] = $row['sample'];
    foreach ($reviewhost['history_table_primary'] as $field) {
        $return['primary'][$field] = $row[$field];
    }
    $return['offset'] = $offset;
} else {
    $return['sample'] = Database::find('review')->query_col('SELECT review.sample
									FROM ' . Database::escapeField($reviewhost['review_table']) . ' AS review
								   WHERE review.checksum = ?', $_REQUEST['checksum']);
}
if (strlen($return['sample'])) {
    $return['sample'] = SqlParser::html($return['sample']);
}
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo json_encode($return);
コード例 #3
0
ファイル: list-ajax.php プロジェクト: qbdsoft/Query-Digest-UI
        if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") {
            $sOrder .= $aColumns[intval($_GET['iSortCol_' . $i])] . " " . $_GET['sSortDir_' . $i] . ", ";
        }
    }
    $sOrder = substr_replace($sOrder, "", -2);
    if ($sOrder == "ORDER BY") {
        $sOrder = "";
    }
    $query .= " {$sOrder} ";
}
if (isset($_GET['iDisplayStart']) && $_GET['iDisplayLength'] != '-1') {
    $query .= " LIMIT " . $_GET['iDisplayStart'] . ", " . $_GET['iDisplayLength'];
}
$list = Database::find('review')->query($query);
$rowCount = (int) Database::find('review')->query_col('SELECT FOUND_ROWS()');
$totalCount = (int) Database::find('review')->query_col('SELECT COUNT(review.checksum) FROM ' . Database::escapeField($reviewhost['review_table']) . ' AS review');
$data = array();
$data['query'] = $query;
$data['sEcho'] = intval(@$_GET['sEcho']);
$data['iTotalRecords'] = $totalCount;
$data['iTotalDisplayRecords'] = $rowCount;
$data['aaData'] = array();
//$data['query']                  = $query;
while ($row = $list->fetch_assoc()) {
    $row['fingerprint'] = SqlParser::htmlPreparedStatement($row['fingerprint'], true);
    $dr = array();
    foreach ($aColumns as $col) {
        $dr[] = $row[$col];
    }
    $dr[] = '<a class="details" href="review.php?checksum=' . $row['checksum'] . '"><img src="images/details_open.png"></a>';
    $data['aaData'][] = $dr;
コード例 #4
0
ファイル: init.php プロジェクト: qbdsoft/Query-Digest-UI
    $settings['defaultColumnVis']['Count'] = false;
    $settings['defaultColumnVis']['TotalMS'] = false;
    $settings['defaultColumnVis']['AvgMS'] = false;
}
if ($settings['oldSlowQueryFormat']) {
    define('Tmp_table_on_disk_cnt', 'Disk_tmp_table_cnt');
    define('Tmp_table_on_disk_sum', 'Disk_tmp_table_sum');
    define('Filesort_on_disk_cnt', 'Disk_filesort_cnt');
    define('Filesort_on_disk_sum', 'Disk_filesort_sum');
} else {
    define('Tmp_table_on_disk_cnt', 'Tmp_table_on_disk_cnt');
    define('Tmp_table_on_disk_sum', 'Tmp_table_on_disk_sum');
    define('Filesort_on_disk_cnt', 'Filesort_on_disk_cnt');
    define('Filesort_on_disk_sum', 'Filesort_on_disk_sum');
}
require_once 'util.php';
require_once 'libs/Database/Database.php';
$options = array('dsn' => $reviewhost['dsn'], PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true);
Database::connect(null, $reviewhost['user'], $reviewhost['password'], null, null, 'pdo', $options, 'review');
// Needed for SqlParser
$dbh = new PDO($reviewhost['dsn'], $reviewhost['user'], $reviewhost['password'], $options);
require_once 'libs/sqlquery/SqlParser.php';
require_once 'classes/QueryRewrite.php';
// Figure out the PRIMARY key for the history table
if (strlen($reviewhost['history_table']) && count($reviewhost['history_table_primary']) == 0) {
    $res = Database::find('review')->query('SHOW INDEXES FROM ' . Database::escapeField($reviewhost['history_table']) . '
												 WHERE key_name = "PRIMARY"');
    while ($row = $res->fetch_assoc()) {
        $reviewhost['history_table_primary'][] = $row['Column_name'];
    }
}
コード例 #5
0
ファイル: explain.php プロジェクト: qbdsoft/Query-Digest-UI
$Query = new QueryRewrite();
$Query->setQuery($query);
$sample = $Query->asExtendedExplain();
$return['QueryRewrite'] = (array) $Query;
$return['oQuery'] = $query;
$return['eQuery'] = $sample;
$return['_REQUEST'] = $_REQUEST;
if (is_null($sample)) {
    $return['Warnings'][] = array('Code' => '0', 'Level' => 'Error', 'Message' => "I can't explain this type of query yet");
} else {
    list($label, $database) = explode('`.`', $_REQUEST['explainDb']);
    $label = str_replace('`', '', $label);
    $database = str_replace('`', '', $database);
    $host = $explainhosts[$label];
    Database::connect(null, $host['user'], $host['password'], null, null, 'pdo', array('dsn' => $host['dsn']), $label);
    Database::find($label)->query('USE ' . Database::escapeField($database));
    Database::find($label)->disable_fatal_errors();
    $query = @Database::find($label)->query($sample);
    Database::find($label)->enable_fatal_errors();
    if (!is_null($query)) {
        while ($row = $query->fetch_assoc()) {
            $row['possible_keys'] = str_replace(',', ', ', $row['possible_keys']);
            $row['ref'] = str_replace(',', ', ', $row['ref']);
            $row['Extra'] = str_replace(array('Using ', ';'), array('', ', '), $row['Extra']);
            foreach ($row as $key => $val) {
                if (is_null($row[$key])) {
                    $row[$key] = '';
                }
                $row[$key] = htmlentities($row[$key]);
            }
            $return['Explain'][] = $row;
コード例 #6
0
ファイル: index.php プロジェクト: qbdsoft/Query-Digest-UI
<?php

require_once 'init.php';
$users = Database::find('review')->query('SELECT DISTINCT reviewed_by FROM ' . Database::escapeField($reviewhost['review_table']) . ' WHERE reviewed_by IS NOT NULL');
$Reviewers = " 'None' ";
while (($user = $users->fetch_col()) !== false) {
    if (strlen($user)) {
        $Reviewers .= ",'{$user}' ";
    }
}
$Reviewers .= " ";
unset($users);
require_once 'templates/header.php';
?>

<table id="Queries">
	<thead>
		<tr>
			<th id="queriesChecksum"      	class="checksum"    > Checksum     </th>
			<th id="queriesColCount"      	class="count"       > Count        </th>
			<th id="queriesColTime"       	class="time"        > Total ms     </th>
			<th id="queriesColAvgTime"    	class="avgTime"     > Avg ms       </th>
            <th id="queriesColtmpDisk"    	class="tmpDisk"     > Tmp Disk     </th>
            <th id="queriesColtmpTbl"    	class="tmpTbl"      > Tmp Tbl       </th>
			<th id="queriesColFirstSeen"  	class="firstSeen"   > First Seen   </th>
			<th id="queriesColLastSeen"   	class="lastSeen"    > Last Seen    </th>
			<th id="queriesColfingerprint"	class="fingerprint"	> Query Fingerprint</th>
			<th id="queriesColReviewedOn" 	class="reviewed_on" > Reviewed On  </th>
			<th id="queriesColReviewedBy" 	class="reviewed_by" > Reviewed By  </th>
			<th id="queriesColComments"   	class="comments"    > Comments     </th>
			<th id="queriesColDetails"    	class="details"     > &nbsp;       </th>