Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
6 / 6 |
CRAP | |
100.00% |
1 / 1 |
MySQLQuery | |
100.00% |
7 / 7 |
|
100.00% |
6 / 6 |
6 | |
100.00% |
1 / 1 |
query | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
sql | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
useConnection | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
startTransaction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
endTransaction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
revertTransaction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Projom\Storage\Query; |
6 | |
7 | use Projom\Storage\Engine; |
8 | use Projom\Storage\Engine\Driver\Driver; |
9 | use Projom\Storage\Query\Action; |
10 | use Projom\Storage\Query\Util; |
11 | use Projom\Storage\SQL\QueryBuilder; |
12 | |
13 | class MySQLQuery |
14 | { |
15 | public static function query(string|array $collections, null|array $options = null): QueryBuilder |
16 | { |
17 | $collections = Util::stringToArray($collections); |
18 | return Engine::dispatch(Action::QUERY, Driver::MySQL, [$collections, $options]); |
19 | } |
20 | |
21 | public static function sql(string $sql, null|array $params = null): mixed |
22 | { |
23 | return Engine::dispatch(Action::EXECUTE, Driver::MySQL, [$sql, $params]); |
24 | } |
25 | |
26 | public static function useConnection(int|string $name): void |
27 | { |
28 | Engine::dispatch(Action::CHANGE_CONNECTION, Driver::MySQL, $name); |
29 | } |
30 | |
31 | public static function startTransaction(): void |
32 | { |
33 | Engine::dispatch(Action::START_TRANSACTION, Driver::MySQL); |
34 | } |
35 | |
36 | public static function endTransaction(): void |
37 | { |
38 | Engine::dispatch(Action::END_TRANSACTION, Driver::MySQL); |
39 | } |
40 | |
41 | public static function revertTransaction(): void |
42 | { |
43 | Engine::dispatch(Action::REVERT_TRANSACTION, Driver::MySQL); |
44 | } |
45 | } |