From df4cddac1f85f56be31d54abe660f1548a81fcd5 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 8 Oct 2020 15:46:18 +0200 Subject: [PATCH] Tracy\Panel: supports multiple connections [Closes #365] Partially reverts "Tracy\Panel: one panel is used per connection" This reverts commit ae6c8756b67496a06c71af912bacaf7ca97c5fc3. --- src/Dibi/Bridges/Tracy/Panel.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Dibi/Bridges/Tracy/Panel.php b/src/Dibi/Bridges/Tracy/Panel.php index 0c59bbd1..8731e25c 100644 --- a/src/Dibi/Bridges/Tracy/Panel.php +++ b/src/Dibi/Bridges/Tracy/Panel.php @@ -105,6 +105,15 @@ class Panel implements Tracy\IBarPanel } $totalTime = $s = null; + + $singleConnection = reset($this->events)->connection; + foreach ($this->events as $event) { + if ($event->connection !== $singleConnection) { + $singleConnection = null; + break; + } + } + foreach ($this->events as $event) { $totalTime += $event->time; $connection = $event->connection; @@ -135,7 +144,10 @@ class Panel implements Tracy\IBarPanel $s .= Tracy\Helpers::editorLink($event->source[0], $event->source[1]);//->class('tracy-DibiProfiler-source'); } - $s .= "{$event->count}"; + $s .= "{$event->count}"; + if (!$singleConnection) { + $s .= '' . htmlspecialchars($this->getConnectionName($connection)) . ''; + } } return '

Queries: ' . count($this->events) . ($totalTime === null ? '' : ', time: ' . number_format($totalTime * 1000, 1, '.', ' ') . ' ms') . ', ' - . htmlspecialchars($connection->getConfig('driver') . ($connection->getConfig('name') ? '/' . $connection->getConfig('name') : '') - . ($connection->getConfig('host') ? ' @ ' . $connection->getConfig('host') : '')) . '

+ . htmlspecialchars($this->getConnectionName($singleConnection)) . '
- ' . $s . ' + ' . (!$singleConnection ? '' : '') . ' + ' . $s . '
Time msSQL StatementRows
Time msSQL StatementRowsConnection
'; } + + + private function getConnectionName(Dibi\Connection $connection): string + { + return $connection->getConfig('driver') + . ($connection->getConfig('name') ? '/' . $connection->getConfig('name') : '') + . ($connection->getConfig('host') ? ' @ ' . $connection->getConfig('host') : ''); + } }