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 | 1 | * @param string $tableName |
|
28 | 1 | * @param string[] $columns |
|
29 | */ |
||
30 | 1 | public function __construct(string $tableName, array $columns) |
|
35 | 1 | ||
36 | /** |
||
37 | * Create INSERT INTO command |
||
38 | * |
||
39 | * @return string INSERT INTO query |
||
40 | */ |
||
41 | public function insertInto(): string |
||
52 | |||
53 | /** |
||
54 | * Create UPDATE SET command with WHERE for updating a single row with ID |
||
55 | * |
||
56 | 2 | * @param array $columns Columns to use in SET condition |
|
57 | 2 | * |
|
58 | * @return string |
||
59 | 2 | */ |
|
60 | public function updateSetWhere(array $columns): string |
||
67 | |||
68 | /** |
||
69 | * Create SELECT FROM command |
||
70 | * |
||
71 | 1 | * @return string SELECT FROM query |
|
72 | 1 | */ |
|
73 | public function selectFrom(): string |
||
79 | |||
80 | /** |
||
81 | * Create SELECT FROM command with WHERE |
||
82 | * |
||
83 | * @param string[] $columns Columns to use in WHERE condition |
||
84 | 1 | * |
|
85 | 1 | * @return string SELECT FROM query |
|
86 | */ |
||
87 | 1 | public function selectFromWhere($columns): string |
|
95 | |||
96 | /** |
||
97 | 2 | * Get columns names for SQL command |
|
98 | 2 | * |
|
99 | * @param String[] $columns |
||
100 | 2 | * |
|
101 | 1 | * @return string Column names for column list |
|
102 | 2 | */ |
|
103 | 1 | protected function getColumnNames(array $columns): string |
|
109 | |||
110 | 1 | /** |
|
111 | * Get columns values for SQL command |
||
112 | * |
||
113 | * @param String[] $columns |
||
114 | * |
||
115 | * @return string Column names for column values |
||
116 | */ |
||
117 | 1 | protected function getColumnValues(array $columns): string |
|
123 | |||
124 | /** |
||
125 | * Get equal string for columns with glue |
||
126 | * |
||
127 | * @param string $glue String glue between columns |
||
128 | * @param array $columns Columns to use |
||
129 | * |
||
130 | * @return string |
||
131 | * |
||
132 | * @throws InvalidEntityPropertyException If provided with columns which the entity dosnt have |
||
133 | */ |
||
134 | protected function getEqualFromColumns(string $glue, array $columns): string |
||
148 | } |
||
149 |