1 | <?php |
||
11 | class Helper |
||
12 | { |
||
13 | /** |
||
14 | * @var ConnectionInterface |
||
15 | */ |
||
16 | public $connection; |
||
17 | |||
18 | protected function __construct(ConnectionInterface $connection) |
||
22 | |||
23 | /** |
||
24 | * @param ConnectionInterface $connection |
||
25 | * |
||
26 | * @return Helper |
||
27 | */ |
||
28 | public static function create(ConnectionInterface $connection) |
||
32 | |||
33 | /** |
||
34 | * Returns a Connection object setup in the construct |
||
35 | * |
||
36 | * @return ConnectionInterface |
||
37 | */ |
||
38 | protected function getConnection() |
||
42 | |||
43 | /** |
||
44 | * Returns a new SphinxQL instance |
||
45 | * |
||
46 | * @return SphinxQL |
||
47 | */ |
||
48 | protected function getSphinxQL() |
||
52 | |||
53 | /** |
||
54 | * Prepares a query in SphinxQL (not executed) |
||
55 | * |
||
56 | * @param $sql |
||
57 | * |
||
58 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
59 | */ |
||
60 | protected function query($sql) |
||
64 | |||
65 | /** |
||
66 | * Converts the columns from queries like SHOW VARIABLES to simpler key-value |
||
67 | * |
||
68 | * @param array $result The result of an executed query |
||
69 | * |
||
70 | * @return array Associative array with Variable_name as key and Value as value |
||
71 | */ |
||
72 | public static function pairsToAssoc($result) |
||
82 | |||
83 | /** |
||
84 | * Runs query: SHOW META |
||
85 | * |
||
86 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
87 | */ |
||
88 | public function showMeta() |
||
92 | |||
93 | /** |
||
94 | * Runs query: SHOW WARNINGS |
||
95 | * |
||
96 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
97 | */ |
||
98 | public function showWarnings() |
||
102 | |||
103 | /** |
||
104 | * Runs query: SHOW STATUS |
||
105 | * |
||
106 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
107 | */ |
||
108 | public function showStatus() |
||
112 | |||
113 | /** |
||
114 | * Runs query: SHOW TABLES |
||
115 | * |
||
116 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
117 | */ |
||
118 | public function showTables() |
||
122 | |||
123 | /** |
||
124 | * Runs query: SHOW VARIABLES |
||
125 | * |
||
126 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
127 | */ |
||
128 | public function showVariables() |
||
132 | |||
133 | /** |
||
134 | * SET syntax |
||
135 | * |
||
136 | * @param string $name The name of the variable |
||
137 | * @param mixed $value The value of the variable |
||
138 | * @param boolean $global True if the variable should be global, false otherwise |
||
139 | * |
||
140 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
141 | */ |
||
142 | public function setVariable($name, $value, $global = false) |
||
165 | |||
166 | /** |
||
167 | * CALL SNIPPETS syntax |
||
168 | * |
||
169 | * @param string $data The document text (or documents) to search |
||
170 | * @param string $index |
||
171 | * @param string $query Search query used for highlighting |
||
172 | * @param array $options Associative array of additional options |
||
173 | * |
||
174 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
175 | */ |
||
176 | public function callSnippets($data, $index, $query, $options = array()) |
||
189 | |||
190 | /** |
||
191 | * CALL KEYWORDS syntax |
||
192 | * |
||
193 | * @param string $text |
||
194 | * @param string $index |
||
195 | * @param null|string $hits |
||
196 | * |
||
197 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
198 | */ |
||
199 | public function callKeywords($text, $index, $hits = null) |
||
208 | |||
209 | /** |
||
210 | * DESCRIBE syntax |
||
211 | * |
||
212 | * @param string $index The name of the index |
||
213 | * |
||
214 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
215 | */ |
||
216 | public function describe($index) |
||
220 | |||
221 | /** |
||
222 | * CREATE FUNCTION syntax |
||
223 | * |
||
224 | * @param string $udf_name |
||
225 | * @param string $returns Whether INT|BIGINT|FLOAT|STRING |
||
226 | * @param string $so_name |
||
227 | * |
||
228 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
229 | */ |
||
230 | public function createFunction($udf_name, $returns, $so_name) |
||
235 | |||
236 | /** |
||
237 | * DROP FUNCTION syntax |
||
238 | * |
||
239 | * @param string $udf_name |
||
240 | * |
||
241 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
242 | */ |
||
243 | public function dropFunction($udf_name) |
||
247 | |||
248 | /** |
||
249 | * ATTACH INDEX * TO RTINDEX * syntax |
||
250 | * |
||
251 | * @param string $disk_index |
||
252 | * @param string $rt_index |
||
253 | * |
||
254 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
255 | */ |
||
256 | public function attachIndex($disk_index, $rt_index) |
||
260 | |||
261 | /** |
||
262 | * FLUSH RTINDEX syntax |
||
263 | * |
||
264 | * @param string $index |
||
265 | * |
||
266 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
267 | */ |
||
268 | public function flushRtIndex($index) |
||
272 | |||
273 | /** |
||
274 | * TRUNCATE RTINDEX syntax |
||
275 | * |
||
276 | * @param string $index |
||
277 | * |
||
278 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
279 | */ |
||
280 | public function truncateRtIndex($index) |
||
284 | |||
285 | /** |
||
286 | * OPTIMIZE INDEX syntax |
||
287 | * |
||
288 | * @param string $index |
||
289 | * |
||
290 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
291 | */ |
||
292 | public function optimizeIndex($index) |
||
296 | |||
297 | /** |
||
298 | * SHOW INDEX STATUS syntax |
||
299 | * |
||
300 | * @param $index |
||
301 | * |
||
302 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
303 | */ |
||
304 | public function showIndexStatus($index) |
||
308 | |||
309 | /** |
||
310 | * FLUSH RAMCHUNK syntax |
||
311 | * |
||
312 | * @param $index |
||
313 | * |
||
314 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
315 | */ |
||
316 | public function flushRamchunk($index) |
||
320 | } |
||
321 |