1 | <?php |
||
12 | class query_builder |
||
13 | { |
||
14 | /** @var \phpbb\auth\auth */ |
||
15 | protected $auth; |
||
16 | |||
17 | /** @var \phpbb\config\config */ |
||
18 | protected $config; |
||
19 | |||
20 | /** @var \phpbb\content_visibility */ |
||
21 | protected $content_visibility; |
||
22 | |||
23 | /** @var \phpbb\db\driver\driver_interface */ |
||
24 | protected $db; |
||
25 | |||
26 | /** @var \phpbb\user */ |
||
27 | protected $user; |
||
28 | |||
29 | /** @var array */ |
||
30 | protected $store; |
||
31 | |||
32 | /** @var array */ |
||
33 | protected $ex_fid_ary; |
||
34 | |||
35 | /** @var integer */ |
||
36 | protected $cache_time; |
||
37 | |||
38 | /** |
||
39 | * Constructor |
||
40 | * |
||
41 | * @param \phpbb\auth\auth $auth Auth object |
||
42 | * @param \phpbb\config\config $config Config object |
||
43 | * @param \phpbb\content_visibility $content_visibility Content visibility |
||
44 | * @param \phpbb\db\driver\driver_interface $db Database connection |
||
45 | * @param \phpbb\user $user User object |
||
46 | * @param integer $cache_time Cache results for 3 hours by default |
||
47 | */ |
||
48 | 16 | public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\content_visibility $content_visibility, \phpbb\db\driver\driver_interface $db, \phpbb\user $user, $cache_time = 10800) |
|
59 | |||
60 | /** |
||
61 | * Begin query |
||
62 | * |
||
63 | * @return $this |
||
64 | */ |
||
65 | 10 | public function query() |
|
84 | |||
85 | /** |
||
86 | * Fetch Forum by id(s) |
||
87 | * |
||
88 | * @param $forum_id |
||
89 | * @return $this |
||
90 | */ |
||
91 | 6 | public function fetch_forum($forum_id) |
|
97 | |||
98 | /** |
||
99 | * Fetch Topic by id(s) |
||
100 | * |
||
101 | * @param mixed $topic_id Limit by topic id: single id or array of topic ids |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function fetch_topic($topic_id) |
||
110 | |||
111 | /** |
||
112 | * Fetch Topic by Poster id(s) |
||
113 | * |
||
114 | * @param mixed $user_id User id of topic poster: single id or array of user ids |
||
115 | * @return $this |
||
116 | */ |
||
117 | public function fetch_topic_poster($user_id) |
||
123 | |||
124 | /** |
||
125 | * Fetch Post by id(s) |
||
126 | * |
||
127 | * @param mixed $post_id Limit by post id: single id or array of post ids |
||
128 | * @return $this |
||
129 | */ |
||
130 | public function fetch_post($post_id) |
||
138 | |||
139 | /** |
||
140 | * Fetch by Topic Type |
||
141 | * |
||
142 | * @param array $topic_type |
||
143 | * @return $this |
||
144 | */ |
||
145 | 6 | public function fetch_topic_type(array $topic_type) |
|
159 | |||
160 | /** |
||
161 | * Fetch Topic Watch info |
||
162 | * |
||
163 | * @return $this |
||
164 | */ |
||
165 | public function fetch_watch_status() |
||
184 | |||
185 | /** |
||
186 | * Fetch Topic Bookmark Info |
||
187 | * |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function fetch_bookmark_status() |
||
203 | |||
204 | /** |
||
205 | * Fetch Topic Tracking Info |
||
206 | * |
||
207 | * @param bool $track |
||
208 | * @return $this |
||
209 | */ |
||
210 | 4 | public function fetch_tracking_info($track = true) |
|
230 | |||
231 | /** |
||
232 | * Fetch by Date Range |
||
233 | * |
||
234 | * @param int $start Unix start time |
||
235 | * @param int $stop Unix stop time |
||
236 | * @param string $mode |
||
237 | * @return $this |
||
238 | */ |
||
239 | 4 | public function fetch_date_range($start, $stop, $mode = 'topic') |
|
248 | |||
249 | /** |
||
250 | * Fetch by Custom Query |
||
251 | * |
||
252 | * @param array $sql_array Array of elements to merge into query |
||
253 | * array( |
||
254 | * 'SELECT' => array('p.*'), |
||
255 | * 'WHERE' => array('p.post_id = 2'), |
||
256 | * ) |
||
257 | * @return $this |
||
258 | */ |
||
259 | 6 | public function fetch_custom(array $sql_array) |
|
265 | |||
266 | /** |
||
267 | * Set Sorting Order |
||
268 | * |
||
269 | * @param string $sort_key The sorting key e.g. t.topic_time |
||
270 | * @param string $sort_dir Sort direction: ASC/DESC |
||
271 | * @return $this |
||
272 | */ |
||
273 | 10 | public function set_sorting($sort_key, $sort_dir = 'DESC') |
|
279 | |||
280 | /** |
||
281 | * Build the query |
||
282 | * |
||
283 | * @param bool|true $check_visibility Should we only return data from forums the user is allowed to see? |
||
284 | * @param bool|true $enable_caching Should the query be cached where possible? |
||
285 | * @return $this |
||
286 | */ |
||
287 | 10 | public function build($check_visibility = true, $enable_caching = true) |
|
300 | |||
301 | /** |
||
302 | * Get the query array |
||
303 | * |
||
304 | * @return array The sql array that can be used with sql_build_query |
||
305 | */ |
||
306 | public function get_sql_array() |
||
310 | |||
311 | /** |
||
312 | * @param bool $enable_caching |
||
313 | */ |
||
314 | 10 | protected function _set_cache_time($enable_caching) |
|
321 | |||
322 | /** |
||
323 | * @param int $column_id |
||
324 | * @param string $column |
||
325 | */ |
||
326 | 6 | private function _fetch($column_id, $column) |
|
333 | |||
334 | /** |
||
335 | * @param bool $check_visibility |
||
336 | */ |
||
337 | 10 | private function _set_topic_visibility($check_visibility) |
|
345 | |||
346 | /** |
||
347 | * Reset data |
||
348 | */ |
||
349 | 10 | private function _reset() |
|
360 | } |
||
361 |