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) |
||
170 | |||
171 | /** |
||
172 | * CALL SNIPPETS syntax |
||
173 | * |
||
174 | * @param string $data The document text (or documents) to search |
||
175 | * @param string $index |
||
176 | * @param string $query Search query used for highlighting |
||
177 | * @param array $options Associative array of additional options |
||
178 | * |
||
179 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
180 | */ |
||
181 | public function callSnippets($data, $index, $query, $options = array()) |
||
194 | |||
195 | /** |
||
196 | * CALL KEYWORDS syntax |
||
197 | * |
||
198 | * @param string $text |
||
199 | * @param string $index |
||
200 | * @param null|string $hits |
||
201 | * |
||
202 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
203 | */ |
||
204 | public function callKeywords($text, $index, $hits = null) |
||
213 | |||
214 | /** |
||
215 | * DESCRIBE syntax |
||
216 | * |
||
217 | * @param string $index The name of the index |
||
218 | * |
||
219 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
220 | */ |
||
221 | public function describe($index) |
||
225 | |||
226 | /** |
||
227 | * CREATE FUNCTION syntax |
||
228 | * |
||
229 | * @param string $udf_name |
||
230 | * @param string $returns Whether INT|BIGINT|FLOAT|STRING |
||
231 | * @param string $so_name |
||
232 | * |
||
233 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
234 | */ |
||
235 | public function createFunction($udf_name, $returns, $so_name) |
||
240 | |||
241 | /** |
||
242 | * DROP FUNCTION syntax |
||
243 | * |
||
244 | * @param string $udf_name |
||
245 | * |
||
246 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
247 | */ |
||
248 | public function dropFunction($udf_name) |
||
252 | |||
253 | /** |
||
254 | * ATTACH INDEX * TO RTINDEX * syntax |
||
255 | * |
||
256 | * @param string $disk_index |
||
257 | * @param string $rt_index |
||
258 | * |
||
259 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
260 | */ |
||
261 | public function attachIndex($disk_index, $rt_index) |
||
266 | |||
267 | /** |
||
268 | * FLUSH RTINDEX syntax |
||
269 | * |
||
270 | * @param string $index |
||
271 | * |
||
272 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
273 | */ |
||
274 | public function flushRtIndex($index) |
||
278 | |||
279 | /** |
||
280 | * OPTIMIZE INDEX syntax |
||
281 | * |
||
282 | * @param string $index |
||
283 | * |
||
284 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
285 | */ |
||
286 | public function optimizeIndex($index) |
||
290 | |||
291 | /** |
||
292 | * SHOW INDEX STATUS syntax |
||
293 | * |
||
294 | * @param $index |
||
295 | * |
||
296 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
297 | */ |
||
298 | public function showIndexStatus($index) |
||
302 | |||
303 | /** |
||
304 | * FLUSH RAMCHUNK syntax |
||
305 | * |
||
306 | * @param $index |
||
307 | * |
||
308 | * @return SphinxQL A SphinxQL object ready to be ->execute(); |
||
309 | */ |
||
310 | public function flushRamchunk($index) |
||
314 | } |
||
315 |