diff --git a/src/Bridges/DatabaseTracy/ConnectionPanel.php b/src/Bridges/DatabaseTracy/ConnectionPanel.php index b3a20088..f1221562 100644 --- a/src/Bridges/DatabaseTracy/ConnectionPanel.php +++ b/src/Bridges/DatabaseTracy/ConnectionPanel.php @@ -70,24 +70,24 @@ private function logQuery(Connection $connection, $result): void $this->count++; - $source = null; $trace = $result instanceof \PDOException - ? $result->getTrace() + ? array_map(fn($row) => array_diff_key($row, ['args' => null]), $result->getTrace()) : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + foreach ($trace as $row) { if (preg_match('~\.(php.?|phtml)$~', $row['file'] ?? '') && !$this->blueScreen->isCollapsed($row['file'])) { - $source = [$row['file'], (int) $row['line']]; break; } + array_shift($trace); } if ($result instanceof Nette\Database\ResultSet) { $this->totalTime += $result->getTime(); if ($this->count < $this->maxQueries) { - $this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), null]; + $this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $trace, $result->getTime(), $result->getRowCount(), null]; } } elseif ($result instanceof \PDOException && $this->count < $this->maxQueries) { - $this->queries[] = [$connection, $result->queryString, null, $source, null, null, $result->getMessage()]; + $this->queries[] = [$connection, $result->queryString, null, $trace, null, null, $result->getMessage()]; } } diff --git a/src/Bridges/DatabaseTracy/dist/panel.phtml b/src/Bridges/DatabaseTracy/dist/panel.phtml index b74abeb3..e8a1f98b 100644 --- a/src/Bridges/DatabaseTracy/dist/panel.phtml +++ b/src/Bridges/DatabaseTracy/dist/panel.phtml @@ -20,7 +20,7 @@ declare(strict_types=1); Rows - + @@ -31,6 +31,8 @@ declare(strict_types=1);
explain +
trace + @@ -54,8 +56,18 @@ declare(strict_types=1); - + + + + + + + + + +
()
+ diff --git a/src/Bridges/DatabaseTracy/panel.latte b/src/Bridges/DatabaseTracy/panel.latte index 37a73198..6199cee1 100644 --- a/src/Bridges/DatabaseTracy/panel.latte +++ b/src/Bridges/DatabaseTracy/panel.latte @@ -17,7 +17,7 @@ Rows - {foreach $queries as [$connection, $sql, $params, $source, $time, $rows, $error, $command, $explain]} + {foreach $queries as [$connection, $sql, $params, $trace, $time, $rows, $error, $command, $explain]} {if $error} @@ -26,6 +26,7 @@ {/if} {if $explain}
explain{/if} + {if $trace}
trace{/if} @@ -48,7 +49,17 @@ {/if} - {if $source}{substr_replace(Tracy\Helpers::editorLink($source[0], $source[1]), ' class="nette-DbConnectionPanel-source"', 2, 0)}{/if} + {if $trace} + {substr_replace(Tracy\Helpers::editorLink($trace[0][file], $trace[0][line]), ' class="nette-DbConnectionPanel-source"', 2, 0)} + + {foreach $trace as $row} + + + + + {/foreach} +
{isset($row[file]) ? Tracy\Helpers::editorLink($row[file], $row[line]) : ''}{$row[class] ?? ''}{$row[type] ?? ''}{$row[function]}()
+ {/if} {$rows} diff --git a/tests/Database.Tracy/panel.html b/tests/Database.Tracy/panel.html index 61863aa4..ffe445c2 100644 --- a/tests/Database.Tracy/panel.html +++ b/tests/Database.Tracy/panel.html @@ -9,7 +9,14 @@

Queries: 4, time: %a% ms, foo

::beginTransaction
- %a%Connection.php:%d% + %a%Connection.php:%d% + + + + + + %A% +
%a%Connection.php:%d%Nette\Utils\Arrays::invoke()
@@ -21,7 +28,8 @@

Queries: 4, time: %a% ms, foo

SELECT 1
%A%
- %a%Connection.php:%d% + %a%Connection.php:%d% + %A%
0 @@ -32,7 +40,8 @@

Queries: 4, time: %a% ms, foo

::commit
- %a%Connection.php:%d% + %a%Connection.php:%d% + %A%
@@ -41,12 +50,14 @@

Queries: 4, time: %a% ms, foo

ERROR +
trace
SELECT
- %a%SqliteDriver.php:%d% + %a%SqliteDriver.php:%d% + %A%