Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Logging;
4
 
5
use Doctrine\Deprecations\Deprecation;
6
 
7
use function microtime;
8
 
9
/**
10
 * Includes executed SQLs in a Debug Stack.
11
 *
12
 * @deprecated
13
 */
14
class DebugStack implements SQLLogger
15
{
16
    /**
17
     * Executed SQL queries.
18
     *
19
     * @var array<int, array<string, mixed>>
20
     */
21
    public $queries = [];
22
 
23
    /**
24
     * If Debug Stack is enabled (log queries) or not.
25
     *
26
     * @var bool
27
     */
28
    public $enabled = true;
29
 
30
    /** @var float|null */
31
    public $start = null;
32
 
33
    /** @var int */
34
    public $currentQuery = 0;
35
 
36
    public function __construct()
37
    {
38
        Deprecation::trigger(
39
            'doctrine/dbal',
40
            'https://github.com/doctrine/dbal/pull/4967',
41
            'DebugStack is deprecated.',
42
        );
43
    }
44
 
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function startQuery($sql, ?array $params = null, ?array $types = null)
49
    {
50
        if (! $this->enabled) {
51
            return;
52
        }
53
 
54
        $this->start = microtime(true);
55
 
56
        $this->queries[++$this->currentQuery] = [
57
            'sql' => $sql,
58
            'params' => $params,
59
            'types' => $types,
60
            'executionMS' => 0,
61
        ];
62
    }
63
 
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function stopQuery()
68
    {
69
        if (! $this->enabled) {
70
            return;
71
        }
72
 
73
        $this->queries[$this->currentQuery]['executionMS'] = microtime(true) - $this->start;
74
    }
75
}