@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class DatabaseCollector extends BaseCollector |
23 | 23 | { |
24 | - /** |
|
24 | + /** |
|
25 | 25 | * {@inheritDoc} |
26 | 26 | */ |
27 | 27 | protected $hasTimeline = true; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
67 | + /** |
|
68 | 68 | * La méthode statique utilisée lors des événements pour collecter des données. |
69 | 69 | */ |
70 | 70 | public static function collect(Event $event) |
@@ -78,141 +78,141 @@ discard block |
||
78 | 78 | // Fournit la valeur par défaut au cas où elle n'est pas définie |
79 | 79 | $max = $config->max_queries ?: 100; |
80 | 80 | |
81 | - if (count(static::$queries) < $max) { |
|
81 | + if (count(static::$queries) < $max) { |
|
82 | 82 | static::$queries[] = (object) $result->details(); |
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * {@inheritDoc} |
|
88 | - */ |
|
89 | - protected function formatTimelineData(): array |
|
90 | - { |
|
91 | - $data = []; |
|
92 | - |
|
93 | - foreach ($this->connections as $alias => $connection) { |
|
94 | - $data[] = [ |
|
95 | - 'name' => 'Connecting to Database: "' . $connection->getDatabase() . '". Config: "' . $alias . '"', |
|
96 | - 'component' => 'Database', |
|
97 | - 'start' => $connection->getConnectStart(), |
|
98 | - 'duration' => $connection->getConnectDuration(), |
|
99 | - ]; |
|
100 | - } |
|
101 | - |
|
102 | - foreach (static::$queries as $query) { |
|
103 | - $data[] = [ |
|
104 | - 'name' => 'Query', |
|
105 | - 'component' => 'Database', |
|
106 | - 'query' => $query->sql, |
|
107 | - 'start' => $query->start, |
|
108 | - 'duration' => $query->duration |
|
109 | - ]; |
|
110 | - } |
|
111 | - |
|
112 | - return $data; |
|
113 | - } |
|
83 | + } |
|
84 | + } |
|
114 | 85 | |
115 | 86 | /** |
116 | - * {@inheritDoc} |
|
117 | - */ |
|
118 | - public function display(): array |
|
119 | - { |
|
120 | - // Mots clés que nous voulons mettre en gras |
|
121 | - $highlight = [ |
|
122 | - 'SELECT', |
|
123 | - 'DISTINCT', |
|
124 | - 'FROM', |
|
125 | - 'WHERE', |
|
126 | - 'AND', |
|
127 | - 'INNER JOIN', |
|
128 | - 'LEFT JOIN', |
|
129 | - 'RIGHT JOIN', |
|
130 | - 'JOIN', |
|
131 | - 'ORDER BY', |
|
132 | - 'ASC', |
|
133 | - 'DESC', |
|
134 | - 'GROUP BY', |
|
135 | - 'LIMIT', |
|
136 | - 'INSERT', |
|
137 | - 'INTO', |
|
138 | - 'VALUES', |
|
139 | - 'UPDATE', |
|
140 | - 'OR ', |
|
141 | - 'HAVING', |
|
142 | - 'OFFSET', |
|
143 | - 'NOT IN', |
|
144 | - 'IN', |
|
145 | - 'NOT LIKE', |
|
146 | - 'LIKE', |
|
147 | - 'COUNT', |
|
148 | - 'MAX', |
|
149 | - 'MIN', |
|
150 | - 'ON', |
|
151 | - 'AS', |
|
152 | - 'AVG', |
|
153 | - 'SUM', |
|
154 | - 'UPPER', |
|
155 | - 'LOWER', |
|
156 | - '(', |
|
157 | - ')', |
|
158 | - ]; |
|
159 | - |
|
160 | - $data = [ |
|
161 | - 'queries' => [], |
|
162 | - ]; |
|
87 | + * {@inheritDoc} |
|
88 | + */ |
|
89 | + protected function formatTimelineData(): array |
|
90 | + { |
|
91 | + $data = []; |
|
92 | + |
|
93 | + foreach ($this->connections as $alias => $connection) { |
|
94 | + $data[] = [ |
|
95 | + 'name' => 'Connecting to Database: "' . $connection->getDatabase() . '". Config: "' . $alias . '"', |
|
96 | + 'component' => 'Database', |
|
97 | + 'start' => $connection->getConnectStart(), |
|
98 | + 'duration' => $connection->getConnectDuration(), |
|
99 | + ]; |
|
100 | + } |
|
101 | + |
|
102 | + foreach (static::$queries as $query) { |
|
103 | + $data[] = [ |
|
104 | + 'name' => 'Query', |
|
105 | + 'component' => 'Database', |
|
106 | + 'query' => $query->sql, |
|
107 | + 'start' => $query->start, |
|
108 | + 'duration' => $query->duration |
|
109 | + ]; |
|
110 | + } |
|
111 | + |
|
112 | + return $data; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * {@inheritDoc} |
|
117 | + */ |
|
118 | + public function display(): array |
|
119 | + { |
|
120 | + // Mots clés que nous voulons mettre en gras |
|
121 | + $highlight = [ |
|
122 | + 'SELECT', |
|
123 | + 'DISTINCT', |
|
124 | + 'FROM', |
|
125 | + 'WHERE', |
|
126 | + 'AND', |
|
127 | + 'INNER JOIN', |
|
128 | + 'LEFT JOIN', |
|
129 | + 'RIGHT JOIN', |
|
130 | + 'JOIN', |
|
131 | + 'ORDER BY', |
|
132 | + 'ASC', |
|
133 | + 'DESC', |
|
134 | + 'GROUP BY', |
|
135 | + 'LIMIT', |
|
136 | + 'INSERT', |
|
137 | + 'INTO', |
|
138 | + 'VALUES', |
|
139 | + 'UPDATE', |
|
140 | + 'OR ', |
|
141 | + 'HAVING', |
|
142 | + 'OFFSET', |
|
143 | + 'NOT IN', |
|
144 | + 'IN', |
|
145 | + 'NOT LIKE', |
|
146 | + 'LIKE', |
|
147 | + 'COUNT', |
|
148 | + 'MAX', |
|
149 | + 'MIN', |
|
150 | + 'ON', |
|
151 | + 'AS', |
|
152 | + 'AVG', |
|
153 | + 'SUM', |
|
154 | + 'UPPER', |
|
155 | + 'LOWER', |
|
156 | + '(', |
|
157 | + ')', |
|
158 | + ]; |
|
159 | + |
|
160 | + $data = [ |
|
161 | + 'queries' => [], |
|
162 | + ]; |
|
163 | 163 | |
164 | 164 | |
165 | - foreach (static::$queries as $query) { |
|
166 | - $sql = $query->sql; |
|
165 | + foreach (static::$queries as $query) { |
|
166 | + $sql = $query->sql; |
|
167 | 167 | |
168 | - foreach ($highlight as $term) { |
|
169 | - $sql = str_replace($term, "<strong>{$term}</strong>", $sql); |
|
170 | - } |
|
168 | + foreach ($highlight as $term) { |
|
169 | + $sql = str_replace($term, "<strong>{$term}</strong>", $sql); |
|
170 | + } |
|
171 | 171 | |
172 | - $data['queries'][] = [ |
|
172 | + $data['queries'][] = [ |
|
173 | 173 | 'duration' => (number_format($query->duration, 5) * 1000) . ' ms', |
174 | 174 | 'sql' => $sql, |
175 | 175 | 'affected_rows' => $query->affected_rows |
176 | - ]; |
|
177 | - } |
|
176 | + ]; |
|
177 | + } |
|
178 | 178 | |
179 | - return $data; |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * {@inheritDoc} |
|
184 | - */ |
|
185 | - public function getBadgeValue(): int |
|
186 | - { |
|
187 | - return count(static::$queries); |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * {@inheritDoc} |
|
192 | - * |
|
193 | - * @return string Le nombre de requêtes (entre parenthèses) ou une chaîne vide. |
|
194 | - */ |
|
195 | - public function getTitleDetails(): string |
|
196 | - { |
|
197 | - return '(' . count(static::$queries) . ' Queries across ' . ($countConnection = count($this->connections)) . ' Connection' . |
|
198 | - ($countConnection > 1 ? 's' : '') . ')'; |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * {@inheritDoc} |
|
203 | - */ |
|
204 | - public function isEmpty(): bool |
|
205 | - { |
|
206 | - return empty(static::$queries); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * {@inheritDoc} |
|
211 | - */ |
|
212 | - public function icon(): string |
|
213 | - { |
|
214 | - return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADMSURBVEhLY6A3YExLSwsA4nIycQDIDIhRWEBqamo/UNF/SjDQjF6ocZgAKPkRiFeEhoYyQ4WIBiA9QAuWAPEHqBAmgLqgHcolGQD1V4DMgHIxwbCxYD+QBqcKINseKo6eWrBioPrtQBq/BcgY5ht0cUIYbBg2AJKkRxCNWkDQgtFUNJwtABr+F6igE8olGQD114HMgHIxAVDyAhA/AlpSA8RYUwoeXAPVex5qHCbIyMgwBCkAuQJIY00huDBUz/mUlBQDqHGjgBjAwAAACexpph6oHSQAAAAASUVORK5CYII='; |
|
215 | - } |
|
179 | + return $data; |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * {@inheritDoc} |
|
184 | + */ |
|
185 | + public function getBadgeValue(): int |
|
186 | + { |
|
187 | + return count(static::$queries); |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * {@inheritDoc} |
|
192 | + * |
|
193 | + * @return string Le nombre de requêtes (entre parenthèses) ou une chaîne vide. |
|
194 | + */ |
|
195 | + public function getTitleDetails(): string |
|
196 | + { |
|
197 | + return '(' . count(static::$queries) . ' Queries across ' . ($countConnection = count($this->connections)) . ' Connection' . |
|
198 | + ($countConnection > 1 ? 's' : '') . ')'; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * {@inheritDoc} |
|
203 | + */ |
|
204 | + public function isEmpty(): bool |
|
205 | + { |
|
206 | + return empty(static::$queries); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * {@inheritDoc} |
|
211 | + */ |
|
212 | + public function icon(): string |
|
213 | + { |
|
214 | + return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADMSURBVEhLY6A3YExLSwsA4nIycQDIDIhRWEBqamo/UNF/SjDQjF6ocZgAKPkRiFeEhoYyQ4WIBiA9QAuWAPEHqBAmgLqgHcolGQD1V4DMgHIxwbCxYD+QBqcKINseKo6eWrBioPrtQBq/BcgY5ht0cUIYbBg2AJKkRxCNWkDQgtFUNJwtABr+F6igE8olGQD114HMgHIxAVDyAhA/AlpSA8RYUwoeXAPVex5qHCbIyMgwBCkAuQJIY00huDBUz/mUlBQDqHGjgBjAwAAACexpph6oHSQAAAAASUVORK5CYII='; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Obtient les connexions à partir de la configuration de la base de données |
@@ -429,7 +429,7 @@ |
||
429 | 429 | */ |
430 | 430 | protected function idValue(array|object $data) |
431 | 431 | { |
432 | - if (is_object($data) && isset($data->{$this->primaryKey})) { |
|
432 | + if (is_object($data) && isset($data->{$this->primaryKey})) { |
|
433 | 433 | return $data->{$this->primaryKey}; |
434 | 434 | } |
435 | 435 |