Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
1.72% |
1 / 58 |
|
1.82% |
1 / 55 |
CRAP | |
0.00% |
0 / 1 |
factory | |
1.72% |
1 / 58 |
|
1.82% |
1 / 55 |
3032.57 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
get_driver | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
set_driver | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
set_debug_load_time | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
set_debug_sql_explain | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_sql_layer | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_db_name | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_any_char | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_one_char | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_db_connect_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_sql_error_triggered | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_sql_error_sql | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_transaction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_sql_time | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_sql_error_returned | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_multi_insert | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
set_multi_insert | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_row_count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_estimated_row_count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_lower_text | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_error | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_buffer_nested_transactions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_bit_or | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_server_info | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_return_on_error | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_build_array | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_fetchrowset | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_transaction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_concatenate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_case | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_build_query | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_fetchfield | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_fetchrow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
cast_expr_to_bigint | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_nextid | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_last_inserted_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_add_num_queries | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_query_limit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_query | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
cast_expr_to_string | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_connect | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_bit_and | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_freeresult | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_num_queries | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_multi_insert | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_affectedrows | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_close | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_rowseek | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_escape | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_like_expression | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_not_like_expression | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_report | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_in_set | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
sql_quote | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
clean_query_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\db\driver; |
15 | |
16 | use Symfony\Component\DependencyInjection\ContainerInterface; |
17 | |
18 | /** |
19 | * Database Abstraction Layer |
20 | */ |
21 | class factory implements driver_interface |
22 | { |
23 | /** |
24 | * @var driver_interface |
25 | */ |
26 | protected $driver = null; |
27 | |
28 | /** |
29 | * @var ContainerInterface |
30 | */ |
31 | protected $container; |
32 | |
33 | /** |
34 | * Constructor. |
35 | * |
36 | * @param ContainerInterface $container A ContainerInterface instance |
37 | */ |
38 | public function __construct(ContainerInterface $container) |
39 | { |
40 | $this->container = $container; |
41 | } |
42 | |
43 | /** |
44 | * Return the current driver (and retrieved it from the container if necessary) |
45 | * |
46 | * @return driver_interface |
47 | */ |
48 | protected function get_driver() |
49 | { |
50 | if ($this->driver === null) |
51 | { |
52 | /** @var driver_interface $driver */ |
53 | $driver = $this->container->get('dbal.conn.driver'); |
54 | $this->driver = $driver; |
55 | } |
56 | |
57 | return $this->driver; |
58 | } |
59 | |
60 | /** |
61 | * Set the current driver |
62 | * |
63 | * @param driver_interface $driver |
64 | */ |
65 | public function set_driver(driver_interface $driver) |
66 | { |
67 | $this->driver = $driver; |
68 | } |
69 | |
70 | /** |
71 | * {@inheritdoc} |
72 | */ |
73 | public function set_debug_load_time($value) |
74 | { |
75 | $this->get_driver()->set_debug_load_time($value); |
76 | } |
77 | |
78 | /** |
79 | * {@inheritdoc} |
80 | */ |
81 | public function set_debug_sql_explain($value) |
82 | { |
83 | $this->get_driver()->set_debug_sql_explain($value); |
84 | } |
85 | |
86 | /** |
87 | * {@inheritdoc} |
88 | */ |
89 | public function get_sql_layer() |
90 | { |
91 | return $this->get_driver()->get_sql_layer(); |
92 | } |
93 | |
94 | /** |
95 | * {@inheritdoc} |
96 | */ |
97 | public function get_db_name() |
98 | { |
99 | return $this->get_driver()->get_db_name(); |
100 | } |
101 | |
102 | /** |
103 | * {@inheritdoc} |
104 | */ |
105 | public function get_any_char() |
106 | { |
107 | return $this->get_driver()->get_any_char(); |
108 | } |
109 | |
110 | /** |
111 | * {@inheritdoc} |
112 | */ |
113 | public function get_one_char() |
114 | { |
115 | return $this->get_driver()->get_one_char(); |
116 | } |
117 | |
118 | /** |
119 | * {@inheritdoc} |
120 | */ |
121 | public function get_db_connect_id() |
122 | { |
123 | return $this->get_driver()->get_db_connect_id(); |
124 | } |
125 | |
126 | /** |
127 | * {@inheritdoc} |
128 | */ |
129 | public function get_sql_error_triggered() |
130 | { |
131 | return $this->get_driver()->get_sql_error_triggered(); |
132 | } |
133 | |
134 | /** |
135 | * {@inheritdoc} |
136 | */ |
137 | public function get_sql_error_sql() |
138 | { |
139 | return $this->get_driver()->get_sql_error_sql(); |
140 | } |
141 | |
142 | /** |
143 | * {@inheritdoc} |
144 | */ |
145 | public function get_transaction() |
146 | { |
147 | return $this->get_driver()->get_transaction(); |
148 | } |
149 | |
150 | /** |
151 | * {@inheritdoc} |
152 | */ |
153 | public function get_sql_time() |
154 | { |
155 | return $this->get_driver()->get_sql_time(); |
156 | } |
157 | |
158 | /** |
159 | * {@inheritdoc} |
160 | */ |
161 | public function get_sql_error_returned() |
162 | { |
163 | return $this->get_driver()->get_sql_error_returned(); |
164 | } |
165 | |
166 | /** |
167 | * {@inheritdoc} |
168 | */ |
169 | public function get_multi_insert() |
170 | { |
171 | return $this->get_driver()->get_multi_insert(); |
172 | } |
173 | |
174 | /** |
175 | * {@inheritdoc} |
176 | */ |
177 | public function set_multi_insert($multi_insert) |
178 | { |
179 | $this->get_driver()->set_multi_insert($multi_insert); |
180 | } |
181 | |
182 | /** |
183 | * {@inheritdoc} |
184 | */ |
185 | public function get_row_count($table_name) |
186 | { |
187 | return $this->get_driver()->get_row_count($table_name); |
188 | } |
189 | |
190 | /** |
191 | * {@inheritdoc} |
192 | */ |
193 | public function get_estimated_row_count($table_name) |
194 | { |
195 | return $this->get_driver()->get_estimated_row_count($table_name); |
196 | } |
197 | |
198 | /** |
199 | * {@inheritdoc} |
200 | */ |
201 | public function sql_lower_text($column_name) |
202 | { |
203 | return $this->get_driver()->sql_lower_text($column_name); |
204 | } |
205 | |
206 | /** |
207 | * {@inheritdoc} |
208 | */ |
209 | public function sql_error($sql = '') |
210 | { |
211 | return $this->get_driver()->sql_error($sql); |
212 | } |
213 | |
214 | /** |
215 | * {@inheritdoc} |
216 | */ |
217 | public function sql_buffer_nested_transactions() |
218 | { |
219 | return $this->get_driver()->sql_buffer_nested_transactions(); |
220 | } |
221 | |
222 | /** |
223 | * {@inheritdoc} |
224 | */ |
225 | public function sql_bit_or($column_name, $bit, $compare = '') |
226 | { |
227 | return $this->get_driver()->sql_bit_or($column_name, $bit, $compare); |
228 | } |
229 | |
230 | /** |
231 | * {@inheritdoc} |
232 | */ |
233 | public function sql_server_info($raw = false, $use_cache = true) |
234 | { |
235 | return $this->get_driver()->sql_server_info($raw, $use_cache); |
236 | } |
237 | |
238 | /** |
239 | * {@inheritdoc} |
240 | */ |
241 | public function sql_return_on_error($fail = false) |
242 | { |
243 | $this->get_driver()->sql_return_on_error($fail); |
244 | } |
245 | |
246 | /** |
247 | * {@inheritdoc} |
248 | */ |
249 | public function sql_build_array($query, $assoc_ary = []) |
250 | { |
251 | return $this->get_driver()->sql_build_array($query, $assoc_ary); |
252 | } |
253 | |
254 | /** |
255 | * {@inheritdoc} |
256 | */ |
257 | public function sql_fetchrowset($query_id = false) |
258 | { |
259 | return $this->get_driver()->sql_fetchrowset($query_id); |
260 | } |
261 | |
262 | /** |
263 | * {@inheritdoc} |
264 | */ |
265 | public function sql_transaction($status = 'begin') |
266 | { |
267 | return $this->get_driver()->sql_transaction($status); |
268 | } |
269 | |
270 | /** |
271 | * {@inheritdoc} |
272 | */ |
273 | public function sql_concatenate($expr1, $expr2) |
274 | { |
275 | return $this->get_driver()->sql_concatenate($expr1, $expr2); |
276 | } |
277 | |
278 | /** |
279 | * {@inheritdoc} |
280 | */ |
281 | public function sql_case($condition, $action_true, $action_false = false) |
282 | { |
283 | return $this->get_driver()->sql_case($condition, $action_true, $action_false); |
284 | } |
285 | |
286 | /** |
287 | * {@inheritdoc} |
288 | */ |
289 | public function sql_build_query($query, $array) |
290 | { |
291 | return $this->get_driver()->sql_build_query($query, $array); |
292 | } |
293 | |
294 | /** |
295 | * {@inheritdoc} |
296 | */ |
297 | public function sql_fetchfield($field, $rownum = false, &$query_id = false) |
298 | { |
299 | return $this->get_driver()->sql_fetchfield($field, $rownum, $query_id); |
300 | } |
301 | |
302 | /** |
303 | * {@inheritdoc} |
304 | */ |
305 | public function sql_fetchrow($query_id = false) |
306 | { |
307 | return $this->get_driver()->sql_fetchrow($query_id); |
308 | } |
309 | |
310 | /** |
311 | * {@inheritdoc} |
312 | */ |
313 | public function cast_expr_to_bigint($expression) |
314 | { |
315 | return $this->get_driver()->cast_expr_to_bigint($expression); |
316 | } |
317 | |
318 | /** |
319 | * {@inheritdoc} |
320 | */ |
321 | public function sql_nextid() |
322 | { |
323 | return $this->get_driver()->sql_last_inserted_id(); |
324 | } |
325 | |
326 | /** |
327 | * {@inheritdoc} |
328 | */ |
329 | public function sql_last_inserted_id() |
330 | { |
331 | return $this->get_driver()->sql_last_inserted_id(); |
332 | } |
333 | |
334 | /** |
335 | * {@inheritdoc} |
336 | */ |
337 | public function sql_add_num_queries($cached = false) |
338 | { |
339 | $this->get_driver()->sql_add_num_queries($cached); |
340 | } |
341 | |
342 | /** |
343 | * {@inheritdoc} |
344 | */ |
345 | public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) |
346 | { |
347 | return $this->get_driver()->sql_query_limit($query, $total, $offset, $cache_ttl); |
348 | } |
349 | |
350 | /** |
351 | * {@inheritdoc} |
352 | */ |
353 | public function sql_query($query = '', $cache_ttl = 0) |
354 | { |
355 | return $this->get_driver()->sql_query($query, $cache_ttl); |
356 | } |
357 | |
358 | /** |
359 | * {@inheritdoc} |
360 | */ |
361 | public function cast_expr_to_string($expression) |
362 | { |
363 | return $this->get_driver()->cast_expr_to_string($expression); |
364 | } |
365 | |
366 | /** |
367 | * {@inheritdoc} |
368 | */ |
369 | public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) |
370 | { |
371 | throw new \Exception('Disabled method.'); |
372 | } |
373 | |
374 | /** |
375 | * {@inheritdoc} |
376 | */ |
377 | public function sql_bit_and($column_name, $bit, $compare = '') |
378 | { |
379 | return $this->get_driver()->sql_bit_and($column_name, $bit, $compare); |
380 | } |
381 | |
382 | /** |
383 | * {@inheritdoc} |
384 | */ |
385 | public function sql_freeresult($query_id = false) |
386 | { |
387 | $this->get_driver()->sql_freeresult($query_id); |
388 | } |
389 | |
390 | /** |
391 | * {@inheritdoc} |
392 | */ |
393 | public function sql_num_queries($cached = false) |
394 | { |
395 | return $this->get_driver()->sql_num_queries($cached); |
396 | } |
397 | |
398 | /** |
399 | * {@inheritdoc} |
400 | */ |
401 | public function sql_multi_insert($table, $sql_ary) |
402 | { |
403 | return $this->get_driver()->sql_multi_insert($table, $sql_ary); |
404 | } |
405 | |
406 | /** |
407 | * {@inheritdoc} |
408 | */ |
409 | public function sql_affectedrows() |
410 | { |
411 | return $this->get_driver()->sql_affectedrows(); |
412 | } |
413 | |
414 | /** |
415 | * {@inheritdoc} |
416 | */ |
417 | public function sql_close() |
418 | { |
419 | return $this->get_driver()->sql_close(); |
420 | } |
421 | |
422 | /** |
423 | * {@inheritdoc} |
424 | */ |
425 | public function sql_rowseek($rownum, &$query_id) |
426 | { |
427 | return $this->get_driver()->sql_rowseek($rownum, $query_id); |
428 | } |
429 | |
430 | /** |
431 | * {@inheritdoc} |
432 | */ |
433 | public function sql_escape($msg) |
434 | { |
435 | return $this->get_driver()->sql_escape($msg); |
436 | } |
437 | |
438 | /** |
439 | * {@inheritdoc} |
440 | */ |
441 | public function sql_like_expression($expression) |
442 | { |
443 | return $this->get_driver()->sql_like_expression($expression); |
444 | } |
445 | |
446 | /** |
447 | * {@inheritdoc} |
448 | */ |
449 | public function sql_not_like_expression($expression) |
450 | { |
451 | return $this->get_driver()->sql_not_like_expression($expression); |
452 | } |
453 | |
454 | /** |
455 | * {@inheritdoc} |
456 | */ |
457 | public function sql_report($mode, $query = '') |
458 | { |
459 | return $this->get_driver()->sql_report($mode, $query); |
460 | } |
461 | |
462 | /** |
463 | * {@inheritdoc} |
464 | */ |
465 | public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) |
466 | { |
467 | return $this->get_driver()->sql_in_set($field, $array, $negate, $allow_empty_set); |
468 | } |
469 | |
470 | /** |
471 | * {@inheritdoc} |
472 | */ |
473 | public function sql_quote($msg) |
474 | { |
475 | return $this->get_driver()->sql_quote($msg); |
476 | } |
477 | |
478 | /** |
479 | * {@inheritDoc} |
480 | */ |
481 | public function clean_query_id(mixed $query_id): int|string|null |
482 | { |
483 | return $this->get_driver()->clean_query_id($query_id); |
484 | } |
485 | } |