Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PluginCategoryMappingsEntityDao | |
0.00% |
0 / 25 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
selectPluginCategoriesByPluginId | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
insertPluginCategoryMapping | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
deletePluginCategoryMappings | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace PeServer\App\Models\Dao\Entities; |
6 | |
7 | use PeServer\Core\Database\DaoBase; |
8 | use PeServer\Core\Database\DaoTrait; |
9 | use PeServer\Core\Database\IDatabaseContext; |
10 | |
11 | class PluginCategoryMappingsEntityDao extends DaoBase |
12 | { |
13 | use DaoTrait; |
14 | |
15 | #region function |
16 | |
17 | /** |
18 | * Undocumented function |
19 | * |
20 | * @param string $pluginId |
21 | * @return array<string> |
22 | */ |
23 | public function selectPluginCategoriesByPluginId(string $pluginId): array |
24 | { |
25 | $results = $this->context->query( |
26 | <<<SQL |
27 | |
28 | select |
29 | plugin_category_mappings.plugin_category_id |
30 | from |
31 | plugin_category_mappings |
32 | where |
33 | plugin_category_mappings.plugin_id = :plugin_id |
34 | |
35 | SQL, |
36 | [ |
37 | 'plugin_id' => $pluginId, |
38 | ] |
39 | ); |
40 | |
41 | return array_map(function ($i) { |
42 | return $i['plugin_category_id']; |
43 | }, $results->rows); |
44 | } |
45 | |
46 | public function insertPluginCategoryMapping(string $pluginId, string $pluginCategoryId): void |
47 | { |
48 | $this->context->insertSingle( |
49 | <<<SQL |
50 | |
51 | insert into |
52 | plugin_category_mappings |
53 | ( |
54 | plugin_id, |
55 | plugin_category_id |
56 | ) |
57 | values |
58 | ( |
59 | :plugin_id, |
60 | :plugin_category_id |
61 | ) |
62 | |
63 | SQL, |
64 | [ |
65 | 'plugin_id' => $pluginId, |
66 | 'plugin_category_id' => $pluginCategoryId, |
67 | ] |
68 | ); |
69 | } |
70 | |
71 | public function deletePluginCategoryMappings(string $pluginId): int |
72 | { |
73 | return $this->context->delete( |
74 | <<<SQL |
75 | |
76 | delete |
77 | from |
78 | plugin_category_mappings |
79 | where |
80 | plugin_id = :plugin_id |
81 | |
82 | SQL, |
83 | [ |
84 | 'plugin_id' => $pluginId, |
85 | ] |
86 | ); |
87 | } |
88 | |
89 | #endregion |
90 | } |