1 | <?php |
||
15 | class Query |
||
16 | { |
||
17 | /** |
||
18 | * |
||
19 | */ |
||
20 | const TYPE_QUERY = 'QUERY'; |
||
21 | /** |
||
22 | * |
||
23 | */ |
||
24 | const TYPE_SELECT = 'SELECT'; |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | */ |
||
29 | const TYPE_INSERT = 'INSERT'; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | public $table; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $attributes = array( |
||
40 | 'where' => array(), |
||
41 | 'columns' => array() |
||
42 | ); |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $type = "SELECT"; |
||
48 | |||
49 | /** |
||
50 | * @param null $table |
||
51 | */ |
||
52 | public function __construct($table = null) |
||
56 | |||
57 | /** |
||
58 | * @param $queryStr |
||
59 | * @param $params |
||
60 | * @return Query |
||
61 | */ |
||
62 | public static function sql($queryStr, $params = null) |
||
72 | |||
73 | /** |
||
74 | * @param $table |
||
75 | * @return Query |
||
76 | */ |
||
77 | public static function table($table) |
||
81 | |||
82 | /** |
||
83 | * @param $table |
||
84 | */ |
||
85 | public function setTable($table) |
||
89 | |||
90 | /** |
||
91 | * @param $columns |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function select($columns = null) |
||
100 | |||
101 | /** |
||
102 | * @param array $columnsVal |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function insert(array $columnsVal) |
||
112 | |||
113 | /** |
||
114 | * @param $query |
||
115 | * @param string $type |
||
116 | * @return Query |
||
117 | */ |
||
118 | public function whereQ(Query $query, $type = "AND") |
||
125 | |||
126 | /** |
||
127 | * @param $column |
||
128 | * @param $value |
||
129 | * @param string $operator |
||
130 | * @param string $type |
||
131 | * @return Query |
||
132 | */ |
||
133 | public function where($column, $value, $operator = "=", $type = "AND") |
||
138 | |||
139 | /** |
||
140 | * @param $column |
||
141 | * @param $value |
||
142 | * @param string $operator |
||
143 | * @return Query |
||
144 | */ |
||
145 | public function andWhere($column, $value, $operator = "=") |
||
149 | |||
150 | /** |
||
151 | * @param $column |
||
152 | * @param $value |
||
153 | * @param string $operator |
||
154 | * @return Query |
||
155 | */ |
||
156 | public function orWhere($column, $value, $operator = "=") |
||
160 | |||
161 | /** |
||
162 | * @param $column |
||
163 | * @param $value |
||
164 | * @param string $type |
||
165 | * @return Query |
||
166 | */ |
||
167 | public function like($column, $value, $type = "AND") |
||
171 | |||
172 | /** |
||
173 | * @param $column |
||
174 | * @param $value |
||
175 | * @return Query |
||
176 | */ |
||
177 | public function andLike($column, $value) |
||
181 | |||
182 | /** |
||
183 | * @param $column |
||
184 | * @param $value |
||
185 | * @return Query |
||
186 | */ |
||
187 | public function orLike($column, $value) |
||
191 | |||
192 | /** |
||
193 | * @param $column |
||
194 | * @param array $value |
||
195 | * @param string $type |
||
196 | * @return Query |
||
197 | */ |
||
198 | public function between($column, $value = array(), $type = "AND") |
||
206 | |||
207 | /** |
||
208 | * @param $column |
||
209 | * @param array $value |
||
210 | * @return Query |
||
211 | */ |
||
212 | public function andBetween($column, $value = array()) |
||
216 | |||
217 | /** |
||
218 | * @param $column |
||
219 | * @param $value |
||
220 | * @return Query |
||
221 | */ |
||
222 | public function orBetween($column, $value) |
||
226 | |||
227 | /** |
||
228 | * @param Grammar $grammar |
||
229 | * @return array |
||
230 | */ |
||
231 | public function build(Grammar $grammar) |
||
243 | |||
244 | /** |
||
245 | * Clear Query Builder |
||
246 | */ |
||
247 | public function clear() |
||
252 | |||
253 | /** |
||
254 | * @param $name |
||
255 | * @return array |
||
256 | */ |
||
257 | public function __get($name) |
||
261 | |||
262 | /** |
||
263 | * @param $name |
||
264 | * @param $value |
||
265 | */ |
||
266 | public function __set($name, $value) |
||
270 | |||
271 | /** |
||
272 | * @return string |
||
273 | */ |
||
274 | public function getType() |
||
278 | |||
279 | /** |
||
280 | * @param string $type |
||
281 | */ |
||
282 | public function setType($type) |
||
286 | } |
||
287 |