-
-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathConnectionPanel.panel.phtml
More file actions
67 lines (62 loc) · 2.47 KB
/
ConnectionPanel.panel.phtml
File metadata and controls
67 lines (62 loc) · 2.47 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
declare(strict_types=1);
namespace Nette\Bridges\DatabaseTracy;
use Nette\Database\Helpers as DbHelpers;
use Tracy;
use Tracy\Helpers;
?>
<style class="tracy-debug">
#tracy-debug td.nette-DbConnectionPanel-sql { background: white !important }
#tracy-debug .nette-DbConnectionPanel-source { color: #BBB !important }
#tracy-debug .nette-DbConnectionPanel-explain td { white-space: pre }
#tracy-debug td.nette-DbConnectionPanel-sql-insert { background: #E7ffE7 !important }
#tracy-debug td.nette-DbConnectionPanel-sql-delete { background: #FFE7E7 !important }
#tracy-debug td.nette-DbConnectionPanel-sql-update { background: #E7FBFF !important }
</style>
<h1 title="<?= Helpers::escapeHtml($connection->getDsn()) ?>">Queries: <?php
echo $count, ($totalTime ? sprintf(', time: %0.3f ms', $totalTime * 1000) : ''), ', ', Helpers::escapeHtml($name) ?></h1>
<div class="tracy-inner">
<div class="tracy-inner-container">
<table class="tracy-sortable">
<tr><th>Time ms</th><th>SQL Query</th><th>Rows</th></tr>
<?php
foreach ($queries as $query):
[$connection, $sql, $params, $source, $time, $rows, $error, $command, $explain] = $query;
?>
<tr>
<td style="background:rgba(255, 95, 23, <?= sprintf('%0.3f', log($time * 1000 + 1, 10) * $performanceScale) ?>)">
<?php if ($error): ?>
<span title="<?= Helpers::escapeHtml($error) ?>">ERROR</span>
<?php elseif ($time !== null): echo sprintf('%0.3f', $time * 1000); endif ?>
<?php if ($explain): ?>
<br /><a class="tracy-toggle tracy-collapsed" data-tracy-ref="^tr .nette-DbConnectionPanel-explain">explain</a>
<?php endif ?>
</td>
<td class="nette-DbConnectionPanel-sql nette-DbConnectionPanel-sql-<?= Helpers::escapeHtml($command) ?>"><?= DbHelpers::dumpSql($sql, $params, $connection) ?>
<?php if ($explain): ?>
<table class="tracy-collapsed nette-DbConnectionPanel-explain">
<tr>
<?php foreach ($explain[0] as $col => $foo): ?>
<th><?= Helpers::escapeHtml($col) ?></th>
<?php endforeach ?>
</tr>
<?php foreach ($explain as $row): ?>
<tr>
<?php foreach ($row as $col): ?>
<td><?= Helpers::escapeHtml($col) ?></td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</table>
<?php endif ?>
<?php if ($source) {
echo substr_replace(Helpers::editorLink($source[0], $source[1]), ' class="nette-DbConnectionPanel-source"', 2, 0);
} ?>
</td>
<td><?= $rows ?></td>
</tr>
<?php endforeach ?>
</table>
<?php if (count($queries) < $count): ?><p>...and more</p><?php endif ?>
</div>
</div>