Skip to content

Commit 942764d

Browse files
committed
config file updates to prep for explain support, some code cleanups.
1 parent c44cc75 commit 942764d

File tree

4 files changed

+210
-192
lines changed

4 files changed

+210
-192
lines changed

config.php.example

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
<?php
22

33
$reviewhost = array(
4-
'db_host' => 'hostname:3306',
5-
'db_user' => 'user',
6-
'db_password' => 'password',
7-
'db_database' => 'database',
8-
'review_table' => 'review',
9-
'review_history_table' => 'review_history',
4+
'dsn' => 'mysql:host=hostname:3306;dbname=database',
5+
'user' => 'user',
6+
'password' => 'password',
7+
'review_table' => 'review',
8+
'history_table' => 'review_history',
9+
);
10+
11+
$explainhosts = array(
12+
'label1' => array(
13+
'dsn' => 'mysql:host=hostname1:3306;dbname=database1',
14+
'user' => 'user',
15+
'password' => 'password'
16+
),
17+
'label2' => array(
18+
'dsn' => 'mysql:host=hostname2:3306;dbname=database2',
19+
'user' => 'user',
20+
'password' => 'password'
21+
),
22+
'label3' => array(
23+
'dsn' => 'mysql:host=hostname3:3306;dbname=database3',
24+
'user' => 'user',
25+
'password' => 'password'
26+
)
1027
);

index.php

+15-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
<?php
22

3-
require('config.php');
4-
5-
$dbh = new PDO("mysql:host={$reviewhost['db_host']};dbname={$reviewhost['db_database']}", $reviewhost['db_user'], $reviewhost['db_password']);
6-
3+
require('init.php');
4+
75
$list = $dbh->prepare('SELECT review.checksum AS checksum,
86
SUBSTR(review.fingerprint, 1, 99999) AS sample,
9-
7+
108
DATE(review.first_seen) AS first_seen,
119
DATE(review.last_seen) AS last_seen,
1210
IFNULL(review.reviewed_by, "-") AS reviewed_by,
1311
DATE(review.reviewed_on) AS reviewed_on,
1412
review.comments AS comments,
15-
13+
1614
SUM(history.ts_cnt) AS count,
1715
ROUND(SUM(history.query_time_sum), 2) AS time,
1816
ROUND(SUM(history.query_time_sum)/SUM(history.ts_cnt), 2) AS time_avg
19-
17+
2018
FROM '.$reviewhost['review_table'].' AS review
21-
LEFT JOIN '.$reviewhost['review_history_table'].' AS history
19+
LEFT JOIN '.$reviewhost['history_table'].' AS history
2220
ON history.checksum = review.checksum
2321
GROUP BY review.checksum
2422
');
@@ -51,11 +49,11 @@
5149
echo "<td class='firstSeen date'>".$row['first_seen']."</td>";
5250
echo "<td class='lastSeen date'>".$row['last_seen']."</td>";
5351
echo "<td class='sample'>".$row['sample']."</td>";
54-
52+
5553
echo "<td class='reviewed_on'>".$row['reviewed_on']."</td>";
5654
echo "<td class='reviewed_by'>".$row['reviewed_by']."</td>";
5755
echo "<td class='comments'>".$row['comments']."</td>";
58-
56+
5957
echo '<td class="details"><a class="details" href="review.php?checksum='.$row['checksum'].'"><img src="images/details_open.png"></a></td>';
6058
echo "</tr>";
6159
}
@@ -79,24 +77,24 @@
7977

8078
<script type="text/javascript">
8179
$(function() {
82-
80+
8381
oTable = $('#Queries').dataTable({
8482
"sDom": '"R<"H"rCp>t<"F"il>"',
8583
"bJQueryUI": true,
8684
"bStateSave": true,
8785
"bProcessing": false,
8886
"aaSort": [],
8987
"aoColumnDefs": [
90-
{ "bSearchable": false, "bVisible": true, "aTargets": [ 0 ] },
88+
{ "bSearchable": false, "bVisible": true, "aTargets": [ 0 ] },
9189
{ "bSearchable": false, "bVisible": true, "aTargets": [ 1 ] },
92-
{ "bSearchable": false, "bVisible": true, "aTargets": [ 2 ] },
90+
{ "bSearchable": false, "bVisible": true, "aTargets": [ 2 ] },
9391
{ "bSearchable": false, "bVisible": true, "aTargets": [ 3 ] },
94-
{ "bSearchable": false, "bVisible": true, "aTargets": [ 4 ] },
95-
{ "bSearchable": true, "bVisible": true, "aTargets": [ 5 ] },
92+
{ "bSearchable": false, "bVisible": true, "aTargets": [ 4 ] },
93+
{ "bSearchable": true, "bVisible": true, "aTargets": [ 5 ] },
9694
{ "bSearchable": false, "bVisible": true, "aTargets": [ 6 ] },
9795
{ "bSearchable": true, "bVisible": true, "aTargets": [ 7 ] },
9896
{ "bSearchable": true, "bVisible": true, "aTargets": [ 8 ] },
99-
{ "bSearchable": false, "bVisible": true, "aTargets": [ 9 ], "bSortable": false },
97+
{ "bSearchable": false, "bVisible": true, "aTargets": [ 9 ], "bSortable": false },
10098
],
10199
"oColVis": {
102100
"aiExclude": [ 9 ]
@@ -131,7 +129,7 @@
131129
null
132130
]
133131
});
134-
132+
135133
if (oldVis.length == oTable.fnSettings().aoColumns.length)
136134
for (var i=0; i < oTable.fnSettings().aoColumns.length; i++)
137135
oTable.fnSetColumnVis(i, oldVis[i]);

init.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
require('config.php');
4+
5+
$dbh = new PDO($reviewhost['dsn'], $reviewhost['user'], $reviewhost['password']);

0 commit comments

Comments
 (0)