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 | 31 | 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 | * @param bool $track_topics |
||
64 | * @return $this |
||
65 | */ |
||
66 | 22 | public function query($track_topics = true) |
|
90 | |||
91 | /** |
||
92 | * Fetch Forum by id(s) |
||
93 | * |
||
94 | * @param $forum_id |
||
95 | * @return $this |
||
96 | */ |
||
97 | 17 | public function fetch_forum($forum_id) |
|
103 | |||
104 | /** |
||
105 | * Fetch Topic by id(s) |
||
106 | * |
||
107 | * @param mixed $topic_id Limit by topic id: single id or array of topic ids |
||
108 | * @return $this |
||
109 | */ |
||
110 | 11 | public function fetch_topic($topic_id) |
|
116 | |||
117 | /** |
||
118 | * Fetch Topic by Poster id(s) |
||
119 | * |
||
120 | * @param mixed $user_id User id of topic poster: single id or array of user ids |
||
121 | * @return $this |
||
122 | */ |
||
123 | 3 | public function fetch_topic_poster($user_id) |
|
129 | |||
130 | /** |
||
131 | * Fetch by Topic Type |
||
132 | * |
||
133 | * @param array $topic_type |
||
134 | * @return $this |
||
135 | */ |
||
136 | 17 | public function fetch_topic_type(array $topic_type) |
|
145 | |||
146 | /** |
||
147 | * Fetch Topic Watch info |
||
148 | * |
||
149 | * @param $type |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function fetch_watch_status($type = 'topic') |
||
176 | |||
177 | /** |
||
178 | * Fetch Topic Bookmark Info |
||
179 | * |
||
180 | * @return $this |
||
181 | */ |
||
182 | public function fetch_bookmark_status() |
||
195 | |||
196 | /** |
||
197 | * Fetch Topic Tracking Info |
||
198 | * |
||
199 | * @return $this |
||
200 | */ |
||
201 | 7 | public function fetch_tracking_info() |
|
221 | |||
222 | /** |
||
223 | * Fetch by Date Range |
||
224 | * |
||
225 | * @param int $unix_start_time |
||
226 | * @param int $unix_stop_time |
||
227 | * @param string $mode |
||
228 | * @return $this |
||
229 | */ |
||
230 | 14 | public function fetch_date_range($unix_start_time, $unix_stop_time, $mode = 'topic') |
|
239 | |||
240 | /** |
||
241 | * Fetch by Custom Query |
||
242 | * |
||
243 | * @param array $sql_array Array of elements to merge into query |
||
244 | * array( |
||
245 | * 'SELECT' => array('p.*'), |
||
246 | * 'WHERE' => array('p.post_id = 2'), |
||
247 | * ) |
||
248 | * @return $this |
||
249 | */ |
||
250 | 8 | public function fetch_custom(array $sql_array) |
|
256 | |||
257 | /** |
||
258 | * Set Sorting Order |
||
259 | * |
||
260 | * @param string $sort_key The sorting key e.g. t.topic_time |
||
261 | * @param string $sort_dir Sort direction: ASC/DESC |
||
262 | * @return $this |
||
263 | */ |
||
264 | 13 | public function set_sorting($sort_key, $sort_dir = 'DESC') |
|
270 | |||
271 | /** |
||
272 | * Build the query |
||
273 | * |
||
274 | * @param bool|true $check_visibility Should we only return data from forums the user is allowed to see? |
||
275 | * @param bool|true $enable_caching Should the query be cached where possible? |
||
276 | * @param bool|true $exclude_hidden_forums Leave out hidden forums? |
||
277 | * @return $this |
||
278 | */ |
||
279 | 22 | public function build($check_visibility = true, $enable_caching = true, $exclude_hidden_forums = true) |
|
297 | |||
298 | /** |
||
299 | * Get the query array |
||
300 | * |
||
301 | * @return array The sql array that can be used with sql_build_query |
||
302 | */ |
||
303 | 8 | public function get_sql_array() |
|
307 | |||
308 | /** |
||
309 | * @param bool $enable_caching |
||
310 | */ |
||
311 | 22 | protected function _set_cache_time($enable_caching) |
|
318 | |||
319 | /** |
||
320 | * @param int $column_id |
||
321 | * @param string $column |
||
322 | */ |
||
323 | 17 | private function _fetch($column_id, $column) |
|
330 | |||
331 | /** |
||
332 | * @param bool $check_visibility |
||
333 | */ |
||
334 | 22 | private function _set_topic_visibility($check_visibility) |
|
342 | |||
343 | /** |
||
344 | * Reset data |
||
345 | */ |
||
346 | 22 | private function _reset() |
|
357 | } |
||
358 |