Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/Dibi/Bridges/Tracy/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ public function getPanel(): ?string
}

$totalTime = $s = null;
foreach ($this->events as $event) {
$occurrences = [];

foreach ($this->events as $key => $event) {
$hashSql = md5(preg_replace('/[^[:alnum:]]/u', '', $event->sql));
$hashes[$key] = $hashSql;
$occurrences[$hashSql] = (isset($occurrences[$hashSql]) ? ++$occurrences[$hashSql] : 1);
}

foreach ($this->events as $key => $event) {
$hashSql = $hashes[$key];
$totalTime += $event->time;
$connection = $event->connection;
$explain = null; // EXPLAIN is called here to work SELECT FOUND_ROWS()
Expand All @@ -126,7 +135,9 @@ public function getPanel(): ?string
$counter++;
$s .= "<br /><a href='#tracy-debug-DibiProfiler-row-$counter' class='tracy-toggle tracy-collapsed' rel='#tracy-debug-DibiProfiler-row-$counter'>explain</a>";
}

if ($occurrences[$hashSql] > 1) {
$s .= '<p style="color:red;font-weight:bold">Occurs:' . $occurrences[$hashSql] .'x</p>';
}
$s .= '</td><td class="tracy-DibiProfiler-sql">' . Helpers::dump(strlen($event->sql) > self::$maxLength ? substr($event->sql, 0, self::$maxLength) . '...' : $event->sql, true);
if ($explain) {
$s .= "<div id='tracy-debug-DibiProfiler-row-$counter' class='tracy-collapsed'>{$explain}</div>";
Expand Down