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 | 4 | public function fields(array $fields) |
|
39 | |||
40 | /** |
||
41 | * Example |
||
42 | * $query->table('product'); |
||
43 | * |
||
44 | * @param string $table |
||
45 | * @return $this |
||
46 | */ |
||
47 | 8 | 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->join('sales', 'product.id = sales.id'); |
||
71 | * |
||
72 | * @param string $table |
||
73 | * @param string $filter |
||
74 | * @return $this |
||
75 | */ |
||
76 | 1 | public function leftJoin($table, $filter) |
|
81 | |||
82 | /** |
||
83 | * Example: |
||
84 | * $query->filter('price > [[amount]]', [ 'amount' => 1000] ); |
||
85 | * |
||
86 | * @param string $filter |
||
87 | * @param array $params |
||
88 | * @return $this |
||
89 | */ |
||
90 | 8 | public function where($filter, array $params = []) |
|
95 | |||
96 | /** |
||
97 | * Example: |
||
98 | * $query->groupBy(['name']); |
||
99 | * |
||
100 | * @param array $fields |
||
101 | * @return $this |
||
102 | */ |
||
103 | public function groupBy(array $fields) |
||
109 | |||
110 | /** |
||
111 | * Example: |
||
112 | * $query->orderBy(['price desc']); |
||
113 | * |
||
114 | * @param array $fields |
||
115 | * @return $this |
||
116 | */ |
||
117 | 3 | public function orderBy(array $fields) |
|
123 | |||
124 | public function limit($start, $end) |
||
130 | |||
131 | public function top($top) |
||
137 | |||
138 | public function forUpdate() |
||
144 | |||
145 | 8 | protected function getFields() |
|
153 | |||
154 | 8 | protected function getJoin() |
|
162 | |||
163 | 8 | protected function getWhere() |
|
179 | |||
180 | /** |
||
181 | * @return array |
||
182 | */ |
||
183 | 8 | public function getSelect() |
|
210 | |||
211 | /** |
||
212 | * @return string |
||
213 | * @throws \Exception |
||
214 | */ |
||
215 | 1 | public function getInsert() |
|
229 | |||
230 | /** |
||
231 | * @return array |
||
232 | * @throws \Exception |
||
233 | */ |
||
234 | 1 | public function getUpdate() |
|
256 | |||
257 | /** |
||
258 | * @return array |
||
259 | * @throws \Exception |
||
260 | */ |
||
261 | 2 | public function getDelete() |
|
273 | |||
274 | } |
||
275 |