1 | <?php |
||
14 | class Query |
||
15 | { |
||
16 | protected $fields = []; |
||
17 | protected $table = ""; |
||
18 | protected $where = []; |
||
19 | protected $groupBy = []; |
||
20 | protected $orderBy = []; |
||
21 | protected $join = []; |
||
22 | |||
23 | protected $forUpdate = false; |
||
24 | |||
25 | /** |
||
26 | * Example: |
||
27 | * $query->fields(['name', 'price']); |
||
28 | * |
||
29 | * @param array $fields |
||
30 | * @return $this |
||
31 | */ |
||
32 | 14 | public function fields(array $fields) |
|
38 | |||
39 | /** |
||
40 | * Example |
||
41 | * $query->table('product'); |
||
42 | * |
||
43 | * @param string $table |
||
44 | * @return $this |
||
45 | */ |
||
46 | 25 | public function table($table) |
|
52 | |||
53 | /** |
||
54 | * Example: |
||
55 | * $query->join('sales', 'product.id = sales.id'); |
||
56 | * |
||
57 | * @param string $table |
||
58 | * @param string $filter |
||
59 | * @return $this |
||
60 | */ |
||
61 | 1 | public function join($table, $filter) |
|
66 | |||
67 | /** |
||
68 | * Example: |
||
69 | * $query->join('sales', 'product.id = sales.id'); |
||
70 | * |
||
71 | * @param string $table |
||
72 | * @param string $filter |
||
73 | * @return $this |
||
74 | */ |
||
75 | 1 | public function leftJoin($table, $filter) |
|
80 | |||
81 | /** |
||
82 | * Example: |
||
83 | * $query->filter('price > [[amount]]', [ 'amount' => 1000] ); |
||
84 | * |
||
85 | * @param string $filter |
||
86 | * @param array $params |
||
87 | * @return $this |
||
88 | */ |
||
89 | 20 | public function where($filter, array $params = []) |
|
94 | |||
95 | /** |
||
96 | * Example: |
||
97 | * $query->groupBy(['name']); |
||
98 | * |
||
99 | * @param array $fields |
||
100 | * @return $this |
||
101 | */ |
||
102 | 1 | public function groupBy(array $fields) |
|
108 | |||
109 | /** |
||
110 | * Example: |
||
111 | * $query->orderBy(['price desc']); |
||
112 | * |
||
113 | * @param array $fields |
||
114 | * @return $this |
||
115 | */ |
||
116 | 4 | public function orderBy(array $fields) |
|
122 | |||
123 | public function forUpdate() |
||
129 | |||
130 | 20 | protected function getFields() |
|
138 | |||
139 | 20 | protected function getJoin() |
|
147 | |||
148 | 24 | protected function getWhere() |
|
164 | |||
165 | /** |
||
166 | * @return array |
||
167 | */ |
||
168 | 20 | public function getSelect() |
|
195 | |||
196 | /** |
||
197 | * @param \ByJG\AnyDataset\DbFunctionsInterface|null $dbHelper |
||
198 | * @return string |
||
199 | * @throws \Exception |
||
200 | */ |
||
201 | 6 | public function getInsert(DbFunctionsInterface $dbHelper = null) |
|
225 | |||
226 | /** |
||
227 | * @param \ByJG\AnyDataset\DbFunctionsInterface|null $dbHelper |
||
228 | * @return array |
||
229 | * @throws \Exception |
||
230 | */ |
||
231 | 5 | public function getUpdate(DbFunctionsInterface $dbHelper = null) |
|
262 | |||
263 | /** |
||
264 | * @return array |
||
265 | * @throws \Exception |
||
266 | */ |
||
267 | 5 | public function getDelete() |
|
279 | |||
280 | } |
||
281 |