forked from mihasya/ishmael
-
Notifications
You must be signed in to change notification settings - Fork 0
/
table.php
42 lines (36 loc) · 1.46 KB
/
table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
#
# 'table' UI - search for queries on a given table
#
require_once('init.php');
$table = mysql_real_escape_string($_GET['table']);
$hours = mysql_real_escape_string($_GET['hours']);
$q = "SELECT
t.sample as query, sum(h.ts_cnt) as count, t.checksum as checksum, t.fingerprint as fingerprint
from
{$host_conf['db_query_review_table']} as t
join
{$host_conf['db_query_review_history_table']} as h
on
t.checksum=h.checksum
where
t.sample like '%{$table}%'
AND
h.ts_max > date_sub(now(),interval {$hours} hour)
group by t.checksum order by count desc";
$result=mysql_query($q);
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
if ($conf['anon']) {
if (preg_match('@/\* (\S+)(::\S+)?.*\*/@', $row['sample'], $matches)) {
$c = ($matches[2]) ? $matches[1] . $matches[2] : $matches[1];
$row['query'] = '/* ' . $c . ' */ ' . $row['fingerprint'];
} else {
$row['query'] = $row['fingerprint'];
}
}
$row['explain_url'] = "explain.php?" . ish_build_query(array('checksum'=>$row['checksum']));
$row['more_url'] = "more.php?" . ish_build_query(array('checksum'=>$row['checksum']));
$rows[] = $row;
}
require("table.tpl");