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 | * @var array |
||
28 | */ |
||
29 | protected $attributes = array( |
||
30 | 'where' => array(), |
||
31 | 'columns' => array() |
||
32 | ); |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $type = "SELECT"; |
||
38 | |||
39 | /** |
||
40 | * @param null $table |
||
41 | */ |
||
42 | public function __construct($table = null) |
||
46 | |||
47 | /** |
||
48 | * @param $queryStr |
||
49 | * @param $params |
||
50 | * @return Query |
||
51 | */ |
||
52 | public static function sql($queryStr, $params = null) |
||
62 | |||
63 | /** |
||
64 | * @param $table |
||
65 | * @return Query |
||
66 | */ |
||
67 | public static function table($table) |
||
71 | |||
72 | /** |
||
73 | * @param $table |
||
74 | */ |
||
75 | public function setTable($table) |
||
79 | |||
80 | /** |
||
81 | * @param $columns |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function select($columns = null) |
||
90 | |||
91 | /** |
||
92 | * @param $query |
||
93 | * @param string $type |
||
94 | * @return Query |
||
95 | */ |
||
96 | public function whereQ(Query $query, $type = "AND") |
||
103 | |||
104 | /** |
||
105 | * @param $column |
||
106 | * @param $value |
||
107 | * @param string $operator |
||
108 | * @param string $type |
||
109 | * @return Query |
||
110 | */ |
||
111 | public function where($column, $value, $operator = "=", $type = "AND") |
||
116 | |||
117 | /** |
||
118 | * @param $column |
||
119 | * @param $value |
||
120 | * @param string $operator |
||
121 | * @return Query |
||
122 | */ |
||
123 | public function andWhere($column, $value, $operator = "=") |
||
127 | |||
128 | /** |
||
129 | * @param $column |
||
130 | * @param $value |
||
131 | * @param string $operator |
||
132 | * @return Query |
||
133 | */ |
||
134 | public function orWhere($column, $value, $operator = "=") |
||
138 | |||
139 | /** |
||
140 | * @param $column |
||
141 | * @param $value |
||
142 | * @param string $type |
||
143 | * @return Query |
||
144 | */ |
||
145 | public function like($column, $value, $type = "AND") |
||
149 | |||
150 | /** |
||
151 | * @param $column |
||
152 | * @param $value |
||
153 | * @return Query |
||
154 | */ |
||
155 | public function andLike($column, $value) |
||
159 | |||
160 | /** |
||
161 | * @param $column |
||
162 | * @param $value |
||
163 | * @return Query |
||
164 | */ |
||
165 | public function orLike($column, $value) |
||
169 | |||
170 | /** |
||
171 | * @param Grammar $grammar |
||
172 | * @return array |
||
173 | */ |
||
174 | public function build(Grammar $grammar) |
||
183 | |||
184 | /** |
||
185 | * @param $name |
||
186 | * @return array |
||
187 | */ |
||
188 | public function __get($name) |
||
192 | |||
193 | /** |
||
194 | * @param $name |
||
195 | * @param $value |
||
196 | */ |
||
197 | public function __set($name, $value) |
||
201 | |||
202 | /** |
||
203 | * @return string |
||
204 | */ |
||
205 | public function getType() |
||
209 | |||
210 | /** |
||
211 | * @param string $type |
||
212 | */ |
||
213 | public function setType($type) |
||
217 | } |
||
218 |