1 | <?php |
||
13 | class SQLCommand |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var String Table name |
||
18 | */ |
||
19 | private $tableName; |
||
20 | |||
21 | /** |
||
22 | * @var String[] Table columns |
||
23 | */ |
||
24 | private $columns; |
||
25 | |||
26 | /** |
||
27 | * @param string $tableName |
||
28 | * @param string[] $columns |
||
29 | */ |
||
30 | 1 | public function __construct(string $tableName, array $columns) |
|
35 | |||
36 | /** |
||
37 | * Create INSERT INTO command |
||
38 | * |
||
39 | * @return string INSERT INTO query |
||
40 | */ |
||
41 | 1 | public function insertInto(): string |
|
48 | |||
49 | /** |
||
50 | * Create UPDATE SET command with WHERE for updating a single row with UUID |
||
51 | * |
||
52 | * @param array $columns Columns to use in SET condition |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | 1 | public function updateSetWhere(array $columns): string |
|
63 | |||
64 | /** |
||
65 | * Create SELECT FROM command |
||
66 | * |
||
67 | * @return string SELECT FROM query |
||
68 | */ |
||
69 | 1 | public function selectFrom(): string |
|
75 | |||
76 | /** |
||
77 | * Create SELECT FROM command with WHERE |
||
78 | * |
||
79 | * @param string[] $columns Columns to use in WHERE condition |
||
80 | * |
||
81 | * @return string SELECT FROM query |
||
82 | */ |
||
83 | 1 | public function selectFromWhere($columns): string |
|
91 | |||
92 | /** |
||
93 | * Get columns names for SQL command |
||
94 | * |
||
95 | * @param String[] $columns |
||
96 | * |
||
97 | * @return string Column names for column list |
||
98 | */ |
||
99 | 1 | protected function getColumnNames(array $columns): string |
|
105 | |||
106 | /** |
||
107 | * Get columns values for SQL command |
||
108 | * |
||
109 | * @param String[] $columns |
||
110 | * |
||
111 | * @return string Column names for column values |
||
112 | */ |
||
113 | 1 | protected function getColumnValues(array $columns): string |
|
119 | |||
120 | /** |
||
121 | * Get equal string for columns with glue |
||
122 | * |
||
123 | * @param string $glue String glue between columns |
||
124 | * @param array $columns Columns to use |
||
125 | * |
||
126 | * @return string |
||
127 | * |
||
128 | * @throws InvalidEntityPropertyException If provided with columns which the entity dosnt have |
||
129 | */ |
||
130 | 2 | protected function getEqualFromColumns(string $glue, array $columns): string |
|
144 | } |
||
145 |