1 | <?php |
||
14 | class Query |
||
15 | { |
||
16 | /** |
||
17 | * |
||
18 | */ |
||
19 | const TYPE_QUERY = 'QUERY'; |
||
20 | /** |
||
21 | * |
||
22 | */ |
||
23 | const TYPE_SELECT = 'SELECT'; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | public $table; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $attributes = array( |
||
34 | 'where' => array(), |
||
35 | 'columns' => array() |
||
36 | ); |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $type = "SELECT"; |
||
42 | |||
43 | /** |
||
44 | * @param null $table |
||
45 | */ |
||
46 | public function __construct($table = null) |
||
50 | |||
51 | /** |
||
52 | * @param $queryStr |
||
53 | * @param $params |
||
54 | * @return Query |
||
55 | */ |
||
56 | public static function sql($queryStr, $params = null) |
||
66 | |||
67 | /** |
||
68 | * @param $table |
||
69 | * @return Query |
||
70 | */ |
||
71 | public static function table($table) |
||
75 | |||
76 | /** |
||
77 | * @param $table |
||
78 | */ |
||
79 | public function setTable($table) |
||
83 | |||
84 | /** |
||
85 | * @param $columns |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function select($columns = null) |
||
94 | |||
95 | /** |
||
96 | * @param $query |
||
97 | * @param string $type |
||
98 | * @return Query |
||
99 | */ |
||
100 | public function whereQ(Query $query, $type = "AND") |
||
107 | |||
108 | /** |
||
109 | * @param $column |
||
110 | * @param $value |
||
111 | * @param string $operator |
||
112 | * @param string $type |
||
113 | * @return Query |
||
114 | */ |
||
115 | public function where($column, $value, $operator = "=", $type = "AND") |
||
120 | |||
121 | /** |
||
122 | * @param $column |
||
123 | * @param $value |
||
124 | * @param string $operator |
||
125 | * @return Query |
||
126 | */ |
||
127 | public function andWhere($column, $value, $operator = "=") |
||
131 | |||
132 | /** |
||
133 | * @param $column |
||
134 | * @param $value |
||
135 | * @param string $operator |
||
136 | * @return Query |
||
137 | */ |
||
138 | public function orWhere($column, $value, $operator = "=") |
||
142 | |||
143 | /** |
||
144 | * @param $column |
||
145 | * @param $value |
||
146 | * @param string $type |
||
147 | * @return Query |
||
148 | */ |
||
149 | public function like($column, $value, $type = "AND") |
||
153 | |||
154 | /** |
||
155 | * @param $column |
||
156 | * @param $value |
||
157 | * @return Query |
||
158 | */ |
||
159 | public function andLike($column, $value) |
||
163 | |||
164 | /** |
||
165 | * @param $column |
||
166 | * @param $value |
||
167 | * @return Query |
||
168 | */ |
||
169 | public function orLike($column, $value) |
||
173 | |||
174 | /** |
||
175 | * @param $column |
||
176 | * @param array $value |
||
177 | * @param string $type |
||
178 | * @return Query |
||
179 | */ |
||
180 | public function between($column, $value = array(), $type = "AND") |
||
188 | |||
189 | /** |
||
190 | * @param $column |
||
191 | * @param array $value |
||
192 | * @return Query |
||
193 | */ |
||
194 | public function andBetween($column, $value = array()) |
||
198 | |||
199 | /** |
||
200 | * @param $column |
||
201 | * @param $value |
||
202 | * @return Query |
||
203 | */ |
||
204 | public function orBetween($column, $value) |
||
208 | |||
209 | /** |
||
210 | * @param Grammar $grammar |
||
211 | * @return array |
||
212 | */ |
||
213 | public function build(Grammar $grammar) |
||
222 | |||
223 | /** |
||
224 | * Clear Query Builder |
||
225 | */ |
||
226 | public function clear() |
||
230 | |||
231 | /** |
||
232 | * @param $name |
||
233 | * @return array |
||
234 | */ |
||
235 | public function __get($name) |
||
239 | |||
240 | /** |
||
241 | * @param $name |
||
242 | * @param $value |
||
243 | */ |
||
244 | public function __set($name, $value) |
||
248 | |||
249 | /** |
||
250 | * @return string |
||
251 | */ |
||
252 | public function getType() |
||
256 | |||
257 | /** |
||
258 | * @param string $type |
||
259 | */ |
||
260 | public function setType($type) |
||
264 | } |
||
265 |