1 | <?php |
||
12 | class Query |
||
13 | { |
||
14 | protected $fields = []; |
||
15 | protected $table = ""; |
||
16 | protected $where = []; |
||
17 | protected $groupBy = []; |
||
18 | protected $orderBy = []; |
||
19 | protected $join = []; |
||
20 | |||
21 | protected $limitStart = null; |
||
22 | protected $limitEnd = null; |
||
23 | protected $top = null; |
||
24 | protected $forUpdate = false; |
||
25 | |||
26 | /** |
||
27 | * Example: |
||
28 | * $query->fields(['name', 'price']); |
||
29 | * |
||
30 | * @param array $fields |
||
31 | * @return $this |
||
32 | */ |
||
33 | 3 | public function fields(array $fields) |
|
39 | |||
40 | /** |
||
41 | * Example |
||
42 | * $query->table('product'); |
||
43 | * |
||
44 | * @param string $table |
||
45 | * @return $this |
||
46 | */ |
||
47 | 7 | public function table($table) |
|
53 | |||
54 | /** |
||
55 | * Example: |
||
56 | * $query->join('sales', 'product.id = sales.id'); |
||
57 | * |
||
58 | * @param string $table |
||
59 | * @param string $filter |
||
60 | * @return $this |
||
61 | */ |
||
62 | 1 | public function join($table, $filter) |
|
67 | |||
68 | /** |
||
69 | * Example: |
||
70 | * $query->filter('price > [[amount]]', [ 'amount' => 1000] ); |
||
71 | * |
||
72 | * @param string $filter |
||
73 | * @param array $params |
||
74 | * @return $this |
||
75 | */ |
||
76 | 7 | public function where($filter, array $params = []) |
|
81 | |||
82 | /** |
||
83 | * Example: |
||
84 | * $query->groupBy(['name']); |
||
85 | * |
||
86 | * @param array $fields |
||
87 | * @return $this |
||
88 | */ |
||
89 | public function groupBy(array $fields) |
||
95 | |||
96 | /** |
||
97 | * Example: |
||
98 | * $query->orderBy(['price desc']); |
||
99 | * |
||
100 | * @param array $fields |
||
101 | * @return $this |
||
102 | */ |
||
103 | 2 | public function orderBy(array $fields) |
|
109 | |||
110 | public function limit($start, $end) |
||
116 | |||
117 | public function top($top) |
||
123 | |||
124 | public function forUpdate() |
||
130 | |||
131 | 7 | protected function getFields() |
|
139 | |||
140 | 7 | protected function getJoin() |
|
148 | |||
149 | 7 | protected function getWhere() |
|
165 | |||
166 | /** |
||
167 | * @return array |
||
168 | */ |
||
169 | 7 | public function getSelect() |
|
196 | |||
197 | /** |
||
198 | * @return string |
||
199 | * @throws \Exception |
||
200 | */ |
||
201 | 1 | public function getInsert() |
|
215 | |||
216 | /** |
||
217 | * @return array |
||
218 | * @throws \Exception |
||
219 | */ |
||
220 | 1 | public function getUpdate() |
|
242 | |||
243 | /** |
||
244 | * @return array |
||
245 | * @throws \Exception |
||
246 | */ |
||
247 | 2 | public function getDelete() |
|
259 | |||
260 | } |
||
261 |