vendor/doctrine/dbal/lib/Doctrine/DBAL/Logging/DebugStack.php line 10

Open in your IDE?
  1. <?php
  2. namespace Doctrine\DBAL\Logging;
  3. use function microtime;
  4. /**
  5.  * Includes executed SQLs in a Debug Stack.
  6.  */
  7. class DebugStack implements SQLLogger
  8. {
  9.     /**
  10.      * Executed SQL queries.
  11.      *
  12.      * @var array<int, array<string, mixed>>
  13.      */
  14.     public $queries = [];
  15.     /**
  16.      * If Debug Stack is enabled (log queries) or not.
  17.      *
  18.      * @var bool
  19.      */
  20.     public $enabled true;
  21.     /** @var float|null */
  22.     public $start null;
  23.     /** @var int */
  24.     public $currentQuery 0;
  25.     /**
  26.      * {@inheritdoc}
  27.      */
  28.     public function startQuery($sql, ?array $params null, ?array $types null)
  29.     {
  30.         if (! $this->enabled) {
  31.             return;
  32.         }
  33.         $this->start microtime(true);
  34.         $this->queries[++$this->currentQuery] = [
  35.             'sql' => $sql,
  36.             'params' => $params,
  37.             'types' => $types,
  38.             'executionMS' => 0,
  39.         ];
  40.     }
  41.     /**
  42.      * {@inheritdoc}
  43.      */
  44.     public function stopQuery()
  45.     {
  46.         if (! $this->enabled) {
  47.             return;
  48.         }
  49.         $this->queries[$this->currentQuery]['executionMS'] = microtime(true) - $this->start;
  50.     }
  51. }