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 |
|
52 | |||
53 | /** |
||
54 | * Create UPDATE SET command with WHERE for updating a single row with ID |
||
55 | * |
||
56 | * @param array $columns Columns to use in SET condition |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | 1 | public function updateSetWhere(array $columns): string |
|
67 | |||
68 | /** |
||
69 | * Create SELECT FROM command |
||
70 | * |
||
71 | * @return string SELECT FROM query |
||
72 | */ |
||
73 | 1 | 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 | * |
||
85 | * @return string SELECT FROM query |
||
86 | */ |
||
87 | 1 | public function selectFromWhere($columns): string |
|
95 | |||
96 | /** |
||
97 | * Get columns names for SQL command |
||
98 | * |
||
99 | * @param String[] $columns |
||
100 | * |
||
101 | * @return string Column names for column list |
||
102 | */ |
||
103 | 1 | protected function getColumnNames(array $columns): string |
|
109 | |||
110 | /** |
||
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 | 1 | protected function getEqualFromColumns(string $glue, array $columns): string |
|
148 | } |
||
149 |