1 | <?php |
||
17 | class StatementProfiler implements ProfilerInterface |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Is the profiler active? |
||
22 | * |
||
23 | * @var boolean |
||
24 | */ |
||
25 | protected $active = false; |
||
26 | |||
27 | /** |
||
28 | * Retained profiles. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $profiles = array(); |
||
33 | |||
34 | /** |
||
35 | * Ignore statements. |
||
36 | * |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $ignoreStatements = array( |
||
40 | 'SELECT LastRevision FROM PluginData WHERE Name = :name', |
||
41 | 'SELECT Id FROM Projects WHERE Path = :path', |
||
42 | ); |
||
43 | |||
44 | /** |
||
45 | * Console IO. |
||
46 | * |
||
47 | * @var ConsoleIO |
||
48 | */ |
||
49 | private $_io; |
||
50 | |||
51 | /** |
||
52 | * Debug mode. |
||
53 | * |
||
54 | * @var boolean |
||
55 | */ |
||
56 | private $_debugMode = false; |
||
57 | |||
58 | /** |
||
59 | * Creates statement profiler |
||
60 | * |
||
61 | * @param ConsoleIO $io Console IO. |
||
62 | */ |
||
63 | 14 | public function __construct(ConsoleIO $io = null) |
|
68 | |||
69 | /** |
||
70 | * Turns the profiler on and off. |
||
71 | * |
||
72 | * @param boolean $active True to turn on, false to turn off. |
||
73 | * |
||
74 | * @return void |
||
75 | */ |
||
76 | 11 | public function setActive($active) |
|
80 | |||
81 | /** |
||
82 | * Is the profiler active? |
||
83 | * |
||
84 | * @return boolean |
||
85 | */ |
||
86 | 13 | public function isActive() |
|
90 | |||
91 | /** |
||
92 | * Adds a profile entry. |
||
93 | * |
||
94 | * @param float $duration The query duration. |
||
95 | * @param string $function The PDO method that made the entry. |
||
96 | * @param string $statement The SQL query statement. |
||
97 | * @param array $bind_values The values bound to the statement. |
||
98 | * |
||
99 | * @return void |
||
100 | * @throws \PDOException When duplicate statement is detected. |
||
101 | */ |
||
102 | 11 | public function addProfile( |
|
142 | |||
143 | /** |
||
144 | * Returns all the profile entries. |
||
145 | * |
||
146 | * @return array |
||
147 | */ |
||
148 | 11 | public function getProfiles() |
|
152 | |||
153 | /** |
||
154 | * Reset all the profiles |
||
155 | * |
||
156 | * @return void |
||
157 | */ |
||
158 | 1 | public function resetProfiles() |
|
162 | |||
163 | } |
||
164 |