Skip to content

Commit 371b1a3

Browse files
committed
Allow add description in debug data
1 parent 0be3912 commit 371b1a3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Database.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,15 +779,17 @@ protected function addToDebug(Closure $function) : mixed
779779
try {
780780
$result = $function();
781781
} catch (Exception $exception) {
782-
$this->finalizeAddToDebug($start);
782+
$this->finalizeAddToDebug($start, $exception->getMessage());
783783
throw $exception;
784784
}
785785
$this->finalizeAddToDebug($start);
786786
return $result;
787787
}
788788

789-
protected function finalizeAddToDebug(float $start) : void
790-
{
789+
protected function finalizeAddToDebug(
790+
float $start,
791+
string|null $description = null
792+
) : void {
791793
$end = \microtime(true);
792794
$rows = $this->mysqli->affected_rows;
793795
$rows = $rows < 0 ? $rows . ' (failed)' : $rows;
@@ -796,6 +798,7 @@ protected function finalizeAddToDebug(float $start) : void
796798
'end' => $end,
797799
'statement' => $this->lastQuery(),
798800
'rows' => $rows,
801+
'description' => $description,
799802
]);
800803
}
801804
}

src/Debug/DatabaseCollector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ public function getContents() : string
102102
\htmlentities($item['statement'])
103103
?></code></pre>
104104
</td>
105-
<td><?= $item['rows'] ?></td>
105+
<td<?= isset($item['description'])
106+
? ' title="' . \htmlentities($item['description']) . '"'
107+
: ''?>><?= \htmlentities((string) $item['rows']) ?></td>
106108
</tr>
107109
<?php endforeach ?>
108110
</tbody>

0 commit comments

Comments
 (0)