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 | * Get table name |
||
38 | * |
||
39 | * @return String Table name |
||
40 | */ |
||
41 | 1 | public function getTableName(): string |
|
45 | |||
46 | /** |
||
47 | * Get table columns |
||
48 | * |
||
49 | * @return \String[] Columns |
||
50 | */ |
||
51 | 1 | public function getColumns(): array |
|
55 | |||
56 | /** |
||
57 | * Create INSERT INTO command |
||
58 | * |
||
59 | * @return string INSERT INTO query |
||
60 | */ |
||
61 | 1 | public function insertInto(): string |
|
68 | |||
69 | /** |
||
70 | * Create UPDATE SET command with WHERE for updating a single row with ID |
||
71 | * |
||
72 | * @param array $columns Columns to use in SET condition |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 1 | public function updateSetWhere(array $columns): string |
|
83 | |||
84 | /** |
||
85 | * Create SELECT FROM command |
||
86 | * |
||
87 | * @return string SELECT FROM query |
||
88 | */ |
||
89 | 1 | public function selectFrom(): string |
|
95 | |||
96 | /** |
||
97 | * Create SELECT FROM command with WHERE |
||
98 | * |
||
99 | * @param string[] $columns Columns to use in WHERE condition |
||
100 | * |
||
101 | * @return string SELECT FROM query |
||
102 | */ |
||
103 | 1 | public function selectFromWhere($columns): string |
|
111 | |||
112 | /** |
||
113 | * Get columns names for SQL command |
||
114 | * |
||
115 | * @param String[] $columns |
||
116 | * |
||
117 | * @return string Column names for column list |
||
118 | */ |
||
119 | 1 | protected function getColumnNames(array $columns): string |
|
125 | |||
126 | /** |
||
127 | * Get columns values for SQL command |
||
128 | * |
||
129 | * @param String[] $columns |
||
130 | * |
||
131 | * @return string Column names for column values |
||
132 | */ |
||
133 | 1 | protected function getColumnValues(array $columns): string |
|
139 | |||
140 | /** |
||
141 | * Get equal string for columns with glue |
||
142 | * |
||
143 | * @param string $glue String glue between columns |
||
144 | * @param array $columns Columns to use |
||
145 | * |
||
146 | * @return string |
||
147 | * |
||
148 | * @throws InvalidEntityPropertyException If provided with columns which the entity dosnt have |
||
149 | */ |
||
150 | 2 | protected function getEqualFromColumns(string $glue, array $columns): string |
|
164 | } |
||
165 |