diff --git a/src/Database/Log/DebugLog.php b/src/Database/Log/DebugLog.php index 8403f132..a9e6d22b 100644 --- a/src/Database/Log/DebugLog.php +++ b/src/Database/Log/DebugLog.php @@ -65,6 +65,13 @@ class DebugLog extends AbstractLogger */ protected bool $_includeSchema = false; + /** + * Whether a transaction is currently open or not. + * + * @var bool + */ + protected bool $inTransaction = false; + /** * Constructor * @@ -162,11 +169,25 @@ public function log($level, string|Stringable $message, array $context = []): vo $this->_totalTime += $data['took']; + $sql = (string)$query; + $isBegin = $sql === 'BEGIN'; + $isCommitOrRollback = $sql === 'COMMIT' || $sql === 'ROLLBACK'; + + if ($isBegin) { + $this->inTransaction = true; + } + $this->_queries[] = [ - 'query' => (string)$query, + 'query' => $sql, 'took' => $data['took'], 'rows' => $data['numRows'], + 'inTransaction' => $this->inTransaction, + 'isCommitOrRollback' => $isCommitOrRollback, ]; + + if ($isCommitOrRollback) { + $this->inTransaction = false; + } } /** diff --git a/templates/element/sql_log_panel.php b/templates/element/sql_log_panel.php index 4fbba0c9..7e6e6d52 100644 --- a/templates/element/sql_log_panel.php +++ b/templates/element/sql_log_panel.php @@ -73,7 +73,7 @@
-