Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like SphinxQL often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SphinxQL, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
13 | class SphinxQL |
||
14 | { |
||
15 | /** |
||
16 | * A non-static connection for the current SphinxQL object |
||
17 | * |
||
18 | * @var ConnectionInterface |
||
19 | */ |
||
20 | protected $connection = null; |
||
21 | |||
22 | /** |
||
23 | * The last result object. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $last_result = null; |
||
28 | |||
29 | /** |
||
30 | * The last compiled query. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $last_compiled = null; |
||
35 | |||
36 | /** |
||
37 | * The last chosen method (select, insert, replace, update, delete). |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $type = null; |
||
42 | |||
43 | /** |
||
44 | * An SQL query that is not yet executed or "compiled" |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $query = null; |
||
49 | |||
50 | /** |
||
51 | * Array of select elements that will be comma separated. |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | protected $select = array(); |
||
56 | |||
57 | /** |
||
58 | * From in SphinxQL is the list of indexes that will be used |
||
59 | * |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $from = array(); |
||
63 | |||
64 | /** |
||
65 | * The list of where and parenthesis, must be inserted in order |
||
66 | * |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $where = array(); |
||
70 | |||
71 | /** |
||
72 | * The list of matches for the MATCH function in SphinxQL |
||
73 | * |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $match = array(); |
||
77 | |||
78 | /** |
||
79 | * GROUP BY array to be comma separated |
||
80 | * |
||
81 | * @var array |
||
82 | */ |
||
83 | protected $group_by = array(); |
||
84 | |||
85 | /** |
||
86 | * ORDER BY array |
||
87 | * |
||
88 | * @var array |
||
89 | */ |
||
90 | protected $within_group_order_by = array(); |
||
91 | |||
92 | /** |
||
93 | * The list of where and parenthesis, must be inserted in order |
||
94 | * |
||
95 | * @var array |
||
96 | */ |
||
97 | protected $having = array(); |
||
98 | |||
99 | /** |
||
100 | * ORDER BY array |
||
101 | * |
||
102 | * @var array |
||
103 | */ |
||
104 | protected $order_by = array(); |
||
105 | |||
106 | /** |
||
107 | * When not null it adds an offset |
||
108 | * |
||
109 | * @var null|int |
||
110 | */ |
||
111 | protected $offset = null; |
||
112 | |||
113 | /** |
||
114 | * When not null it adds a limit |
||
115 | * |
||
116 | * @var null|int |
||
117 | */ |
||
118 | protected $limit = null; |
||
119 | |||
120 | /** |
||
121 | * Value of INTO query for INSERT or REPLACE |
||
122 | * |
||
123 | * @var null|string |
||
124 | */ |
||
125 | protected $into = null; |
||
126 | |||
127 | /** |
||
128 | * Array of columns for INSERT or REPLACE |
||
129 | * |
||
130 | * @var array |
||
131 | */ |
||
132 | protected $columns = array(); |
||
133 | |||
134 | /** |
||
135 | * Array OF ARRAYS of values for INSERT or REPLACE |
||
136 | * |
||
137 | * @var array |
||
138 | */ |
||
139 | protected $values = array(); |
||
140 | |||
141 | /** |
||
142 | * Array arrays containing column and value for SET in UPDATE |
||
143 | * |
||
144 | * @var array |
||
145 | */ |
||
146 | protected $set = array(); |
||
147 | |||
148 | /** |
||
149 | * Array of OPTION specific to SphinxQL |
||
150 | * |
||
151 | * @var array |
||
152 | */ |
||
153 | protected $options = array(); |
||
154 | |||
155 | /** |
||
156 | * Array of FACETs |
||
157 | * |
||
158 | * @var Facet[] |
||
159 | */ |
||
160 | protected $facets = array(); |
||
161 | |||
162 | /** |
||
163 | * The reference to the object that queued itself and created this object |
||
164 | * |
||
165 | * @var null|SphinxQL |
||
166 | */ |
||
167 | protected $queue_prev = null; |
||
168 | |||
169 | /** |
||
170 | * An array of escaped characters for escapeMatch() |
||
171 | * @var array |
||
172 | */ |
||
173 | protected $escape_full_chars = array( |
||
174 | '\\' => '\\\\', |
||
175 | '(' => '\(', |
||
176 | ')' => '\)', |
||
177 | '|' => '\|', |
||
178 | '-' => '\-', |
||
179 | '!' => '\!', |
||
180 | '@' => '\@', |
||
181 | '~' => '\~', |
||
182 | '"' => '\"', |
||
183 | '&' => '\&', |
||
184 | '/' => '\/', |
||
185 | '^' => '\^', |
||
186 | '$' => '\$', |
||
187 | '=' => '\=', |
||
188 | '<' => '\<', |
||
189 | ); |
||
190 | |||
191 | /** |
||
192 | * An array of escaped characters for fullEscapeMatch() |
||
193 | * @var array |
||
194 | */ |
||
195 | protected $escape_half_chars = array( |
||
196 | '\\' => '\\\\', |
||
197 | '(' => '\(', |
||
198 | ')' => '\)', |
||
199 | '!' => '\!', |
||
200 | '@' => '\@', |
||
201 | '~' => '\~', |
||
202 | '&' => '\&', |
||
203 | '/' => '\/', |
||
204 | '^' => '\^', |
||
205 | '$' => '\$', |
||
206 | '=' => '\=', |
||
207 | '<' => '\<', |
||
208 | ); |
||
209 | |||
210 | public function __construct(ConnectionInterface $connection = null, $static = false) |
||
|
|||
211 | { |
||
212 | $this->connection = $connection; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * Creates and setups a SphinxQL object |
||
217 | * |
||
218 | * @param ConnectionInterface $connection |
||
219 | * |
||
220 | * @return SphinxQL |
||
221 | */ |
||
222 | public static function create(ConnectionInterface $connection) |
||
223 | { |
||
224 | return new static($connection); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * Returns the currently attached connection |
||
229 | * |
||
230 | * @returns ConnectionInterface |
||
231 | */ |
||
232 | public function getConnection() |
||
233 | { |
||
234 | return $this->connection; |
||
235 | } |
||
236 | |||
237 | /** |
||
238 | * Avoids having the expressions escaped |
||
239 | * |
||
240 | * Examples: |
||
241 | * $query->where('time', '>', SphinxQL::expr('CURRENT_TIMESTAMP')); |
||
242 | * // WHERE time > CURRENT_TIMESTAMP |
||
243 | * |
||
244 | * @param string $string The string to keep unaltered |
||
245 | * |
||
246 | * @return Expression The new Expression |
||
247 | */ |
||
248 | public static function expr($string = '') |
||
252 | |||
253 | /** |
||
254 | * Runs the query built |
||
255 | * |
||
256 | * @return ResultSetInterface The result of the query |
||
257 | */ |
||
258 | public function execute() |
||
259 | { |
||
260 | // pass the object so execute compiles it by itself |
||
261 | return $this->last_result = $this->getConnection()->query($this->compile()->getCompiled()); |
||
262 | } |
||
263 | |||
264 | /** |
||
265 | * Executes a batch of queued queries |
||
266 | * |
||
267 | * @return MultiResultSetInterface The array of results |
||
268 | * @throws SphinxQLException In case no query is in queue |
||
269 | */ |
||
270 | public function executeBatch() |
||
271 | { |
||
272 | if (count($this->getQueue()) == 0) { |
||
273 | throw new SphinxQLException('There is no Queue present to execute.'); |
||
274 | } |
||
275 | |||
276 | $queue = array(); |
||
277 | |||
278 | foreach ($this->getQueue() as $query) { |
||
279 | $queue[] = $query->compile()->getCompiled(); |
||
280 | } |
||
281 | |||
282 | return $this->last_result = $this->getConnection()->multiQuery($queue); |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * Enqueues the current object and returns a new one or the supplied one |
||
287 | * |
||
288 | * @param SphinxQL|null $next |
||
289 | * |
||
290 | * @return SphinxQL A new SphinxQL object with the current object referenced |
||
291 | */ |
||
292 | public function enqueue(SphinxQL $next = null) |
||
293 | { |
||
294 | if ($next === null) { |
||
295 | $next = new static($this->getConnection()); |
||
296 | } |
||
297 | |||
298 | $next->setQueuePrev($this); |
||
299 | |||
300 | return $next; |
||
301 | } |
||
302 | |||
303 | /** |
||
304 | * Returns the ordered array of enqueued objects |
||
305 | * |
||
306 | * @return SphinxQL[] The ordered array of enqueued objects |
||
307 | */ |
||
308 | public function getQueue() |
||
309 | { |
||
310 | $queue = array(); |
||
311 | $curr = $this; |
||
312 | |||
313 | do { |
||
314 | if ($curr->type != null) { |
||
315 | $queue[] = $curr; |
||
316 | } |
||
317 | } while ($curr = $curr->getQueuePrev()); |
||
318 | |||
319 | return array_reverse($queue); |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * Gets the enqueued object |
||
324 | * |
||
325 | * @return SphinxQL|null |
||
326 | */ |
||
327 | public function getQueuePrev() |
||
328 | { |
||
329 | return $this->queue_prev; |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * Sets the reference to the enqueued object |
||
334 | * |
||
335 | * @param SphinxQL $query The object to set as previous |
||
336 | * |
||
337 | * @return SphinxQL |
||
338 | */ |
||
339 | public function setQueuePrev($query) |
||
340 | { |
||
341 | $this->queue_prev = $query; |
||
342 | |||
343 | return $this; |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * Returns the result of the last query |
||
348 | * |
||
349 | * @return array The result of the last query |
||
350 | */ |
||
351 | public function getResult() |
||
355 | |||
356 | /** |
||
357 | * Returns the latest compiled query |
||
358 | * |
||
359 | * @return string The last compiled query |
||
360 | */ |
||
361 | public function getCompiled() |
||
365 | |||
366 | /** |
||
367 | * Begins transaction |
||
368 | */ |
||
369 | public function transactionBegin() |
||
373 | |||
374 | /** |
||
375 | * Commits transaction |
||
376 | */ |
||
377 | public function transactionCommit() |
||
381 | |||
382 | /** |
||
383 | * Rollbacks transaction |
||
384 | */ |
||
385 | public function transactionRollback() |
||
389 | |||
390 | /** |
||
391 | * Runs the compile function |
||
392 | * |
||
393 | * @return SphinxQL |
||
394 | */ |
||
395 | public function compile() |
||
418 | |||
419 | public function compileQuery() |
||
425 | |||
426 | /** |
||
427 | * Compiles the MATCH part of the queries |
||
428 | * Used by: SELECT, DELETE, UPDATE |
||
429 | * |
||
430 | * @return string The compiled MATCH |
||
431 | */ |
||
432 | public function compileMatch() |
||
433 | { |
||
434 | $query = ''; |
||
435 | |||
436 | if (!empty($this->match)) { |
||
437 | $query .= 'WHERE MATCH('; |
||
438 | |||
439 | $matched = array(); |
||
440 | |||
441 | foreach ($this->match as $match) { |
||
442 | $pre = ''; |
||
443 | if ($match['column'] instanceof \Closure) { |
||
444 | $sub = new Match($this); |
||
445 | call_user_func($match['column'], $sub); |
||
446 | $pre .= $sub->compile()->getCompiled(); |
||
447 | } elseif ($match['column'] instanceof Match) { |
||
448 | $pre .= $match['column']->compile()->getCompiled(); |
||
449 | } elseif (empty($match['column'])) { |
||
450 | $pre .= ''; |
||
451 | } elseif (is_array($match['column'])) { |
||
452 | $pre .= '@('.implode(',', $match['column']).') '; |
||
453 | } else { |
||
454 | $pre .= '@'.$match['column'].' '; |
||
455 | } |
||
456 | |||
457 | if ($match['half']) { |
||
458 | $pre .= $this->halfEscapeMatch($match['value']); |
||
459 | } else { |
||
460 | $pre .= $this->escapeMatch($match['value']); |
||
461 | } |
||
462 | |||
463 | $matched[] = '('.$pre.')'; |
||
464 | } |
||
465 | |||
466 | $matched = implode(' ', $matched); |
||
467 | $query .= $this->getConnection()->escape(trim($matched)).') '; |
||
468 | } |
||
469 | return $query; |
||
470 | } |
||
471 | |||
472 | /** |
||
473 | * Compiles the WHERE part of the queries |
||
474 | * It interacts with the MATCH() and of course isn't usable stand-alone |
||
475 | * Used by: SELECT, DELETE, UPDATE |
||
476 | * |
||
477 | * @return string The compiled WHERE |
||
478 | */ |
||
479 | public function compileWhere() |
||
498 | |||
499 | public function compileFilterCondition($filter) |
||
527 | |||
528 | /** |
||
529 | * Compiles the statements for SELECT |
||
530 | * |
||
531 | * @return SphinxQL |
||
532 | */ |
||
533 | public function compileSelect() |
||
664 | |||
665 | /** |
||
666 | * Compiles the statements for INSERT or REPLACE |
||
667 | * |
||
668 | * @return SphinxQL |
||
669 | */ |
||
670 | public function compileInsert() |
||
702 | |||
703 | /** |
||
704 | * Compiles the statements for UPDATE |
||
705 | * |
||
706 | * @return SphinxQL |
||
707 | */ |
||
708 | public function compileUpdate() |
||
742 | |||
743 | /** |
||
744 | * Compiles the statements for DELETE |
||
745 | * |
||
746 | * @return SphinxQL |
||
747 | */ |
||
748 | public function compileDelete() |
||
765 | |||
766 | /** |
||
767 | * Sets a query to be executed |
||
768 | * |
||
769 | * @param string $sql A SphinxQL query to execute |
||
770 | * |
||
771 | * @return SphinxQL |
||
772 | */ |
||
773 | public function query($sql) |
||
780 | |||
781 | /** |
||
782 | * Select the columns |
||
783 | * |
||
784 | * Gets the arguments passed as $sphinxql->select('one', 'two') |
||
785 | * Using it without arguments equals to having '*' as argument |
||
786 | * Using it with array maps values as column names |
||
787 | * |
||
788 | * Examples: |
||
789 | * $query->select('title'); |
||
790 | * // SELECT title |
||
791 | * |
||
792 | * $query->select('title', 'author', 'date'); |
||
793 | * // SELECT title, author, date |
||
794 | * |
||
795 | * $query->select(['id', 'title']); |
||
796 | * // SELECT id, title |
||
797 | * |
||
798 | * @param array|string $columns Array or multiple string arguments containing column names |
||
799 | * |
||
800 | * @return SphinxQL |
||
801 | */ |
||
802 | View Code Duplication | public function select($columns = null) |
|
815 | |||
816 | /** |
||
817 | * Alters which arguments to select |
||
818 | * |
||
819 | * Query is assumed to be in SELECT mode |
||
820 | * See select() for usage |
||
821 | * |
||
822 | * @param array|string $columns Array or multiple string arguments containing column names |
||
823 | * |
||
824 | * @return SphinxQL |
||
825 | */ |
||
826 | View Code Duplication | public function setSelect($columns = null) |
|
836 | |||
837 | /** |
||
838 | * Get the columns staged to select |
||
839 | * |
||
840 | * @return array |
||
841 | */ |
||
842 | public function getSelect() |
||
846 | |||
847 | /** |
||
848 | * Activates the INSERT mode |
||
849 | * |
||
850 | * @return SphinxQL |
||
851 | */ |
||
852 | public function insert() |
||
859 | |||
860 | /** |
||
861 | * Activates the REPLACE mode |
||
862 | * |
||
863 | * @return SphinxQL |
||
864 | */ |
||
865 | public function replace() |
||
872 | |||
873 | /** |
||
874 | * Activates the UPDATE mode |
||
875 | * |
||
876 | * @param string $index The index to update into |
||
877 | * |
||
878 | * @return SphinxQL |
||
879 | */ |
||
880 | public function update($index) |
||
888 | |||
889 | /** |
||
890 | * Activates the DELETE mode |
||
891 | * |
||
892 | * @return SphinxQL |
||
893 | */ |
||
894 | public function delete() |
||
901 | |||
902 | /** |
||
903 | * FROM clause (Sphinx-specific since it works with multiple indexes) |
||
904 | * func_get_args()-enabled |
||
905 | * |
||
906 | * @param array $array An array of indexes to use |
||
907 | * |
||
908 | * @return SphinxQL |
||
909 | */ |
||
910 | public function from($array = null) |
||
922 | |||
923 | /** |
||
924 | * MATCH clause (Sphinx-specific) |
||
925 | * |
||
926 | * @param mixed $column The column name (can be array, string, Closure, or Match) |
||
927 | * @param string $value The value |
||
928 | * @param boolean $half Exclude ", |, - control characters from being escaped |
||
929 | * |
||
930 | * @return SphinxQL |
||
931 | */ |
||
932 | public function match($column, $value = null, $half = false) |
||
942 | |||
943 | /** |
||
944 | * WHERE clause |
||
945 | * |
||
946 | * Examples: |
||
947 | * $query->where('column', 'value'); |
||
948 | * // WHERE column = 'value' |
||
949 | * |
||
950 | * $query->where('column', '=', 'value'); |
||
951 | * // WHERE column = 'value' |
||
952 | * |
||
953 | * $query->where('column', '>=', 'value') |
||
954 | * // WHERE column >= 'value' |
||
955 | * |
||
956 | * $query->where('column', 'IN', array('value1', 'value2', 'value3')); |
||
957 | * // WHERE column IN ('value1', 'value2', 'value3') |
||
958 | * |
||
959 | * $query->where('column', 'BETWEEN', array('value1', 'value2')) |
||
960 | * // WHERE column BETWEEN 'value1' AND 'value2' |
||
961 | * // WHERE example BETWEEN 10 AND 100 |
||
962 | * |
||
963 | * @param string $column The column name |
||
964 | * @param string $operator The operator to use |
||
965 | * @param string $value The value to check against |
||
966 | * |
||
967 | * @return SphinxQL |
||
968 | */ |
||
969 | View Code Duplication | public function where($column, $operator, $value = null) |
|
984 | |||
985 | /** |
||
986 | * GROUP BY clause |
||
987 | * Adds to the previously added columns |
||
988 | * |
||
989 | * @param string $column A column to group by |
||
990 | * |
||
991 | * @return SphinxQL |
||
992 | */ |
||
993 | public function groupBy($column) |
||
999 | |||
1000 | /** |
||
1001 | * WITHIN GROUP ORDER BY clause (SphinxQL-specific) |
||
1002 | * Adds to the previously added columns |
||
1003 | * Works just like a classic ORDER BY |
||
1004 | * |
||
1005 | * @param string $column The column to group by |
||
1006 | * @param string $direction The group by direction (asc/desc) |
||
1007 | * |
||
1008 | * @return SphinxQL |
||
1009 | */ |
||
1010 | public function withinGroupOrderBy($column, $direction = null) |
||
1016 | |||
1017 | /** |
||
1018 | * HAVING clause |
||
1019 | * |
||
1020 | * Examples: |
||
1021 | * $sq->having('column', 'value'); |
||
1022 | * // HAVING column = 'value' |
||
1023 | * |
||
1024 | * $sq->having('column', '=', 'value'); |
||
1025 | * // HAVING column = 'value' |
||
1026 | * |
||
1027 | * $sq->having('column', '>=', 'value') |
||
1028 | * // HAVING column >= 'value' |
||
1029 | * |
||
1030 | * $sq->having('column', 'IN', array('value1', 'value2', 'value3')); |
||
1031 | * // HAVING column IN ('value1', 'value2', 'value3') |
||
1032 | * |
||
1033 | * $sq->having('column', 'BETWEEN', array('value1', 'value2')) |
||
1034 | * // HAVING column BETWEEN 'value1' AND 'value2' |
||
1035 | * // HAVING example BETWEEN 10 AND 100 |
||
1036 | * |
||
1037 | * @param string $column The column name |
||
1038 | * @param string $operator The operator to use |
||
1039 | * @param string $value The value to check against |
||
1040 | * |
||
1041 | * @return SphinxQL The current object |
||
1042 | */ |
||
1043 | View Code Duplication | public function having($column, $operator, $value = null) |
|
1058 | |||
1059 | /** |
||
1060 | * ORDER BY clause |
||
1061 | * Adds to the previously added columns |
||
1062 | * |
||
1063 | * @param string $column The column to order on |
||
1064 | * @param string $direction The ordering direction (asc/desc) |
||
1065 | * |
||
1066 | * @return SphinxQL |
||
1067 | */ |
||
1068 | public function orderBy($column, $direction = null) |
||
1074 | |||
1075 | /** |
||
1076 | * LIMIT clause |
||
1077 | * Supports also LIMIT offset, limit |
||
1078 | * |
||
1079 | * @param int $offset Offset if $limit is specified, else limit |
||
1080 | * @param null|int $limit The limit to set, null for no limit |
||
1081 | * |
||
1082 | * @return SphinxQL |
||
1083 | */ |
||
1084 | View Code Duplication | public function limit($offset, $limit = null) |
|
1096 | |||
1097 | /** |
||
1098 | * OFFSET clause |
||
1099 | * |
||
1100 | * @param int $offset The offset |
||
1101 | * |
||
1102 | * @return SphinxQL |
||
1103 | */ |
||
1104 | public function offset($offset) |
||
1110 | |||
1111 | /** |
||
1112 | * OPTION clause (SphinxQL-specific) |
||
1113 | * Used by: SELECT |
||
1114 | * |
||
1115 | * @param string $name Option name |
||
1116 | * @param string $value Option value |
||
1117 | * |
||
1118 | * @return SphinxQL |
||
1119 | */ |
||
1120 | public function option($name, $value) |
||
1126 | |||
1127 | /** |
||
1128 | * INTO clause |
||
1129 | * Used by: INSERT, REPLACE |
||
1130 | * |
||
1131 | * @param string $index The index to insert/replace into |
||
1132 | * |
||
1133 | * @return SphinxQL |
||
1134 | */ |
||
1135 | public function into($index) |
||
1141 | |||
1142 | /** |
||
1143 | * Set columns |
||
1144 | * Used in: INSERT, REPLACE |
||
1145 | * func_get_args()-enabled |
||
1146 | * |
||
1147 | * @param array $array The array of columns |
||
1148 | * |
||
1149 | * @return SphinxQL |
||
1150 | */ |
||
1151 | View Code Duplication | public function columns($array = array()) |
|
1161 | |||
1162 | /** |
||
1163 | * Set VALUES |
||
1164 | * Used in: INSERT, REPLACE |
||
1165 | * func_get_args()-enabled |
||
1166 | * |
||
1167 | * @param array $array The array of values matching the columns from $this->columns() |
||
1168 | * |
||
1169 | * @return SphinxQL |
||
1170 | */ |
||
1171 | public function values($array) |
||
1181 | |||
1182 | /** |
||
1183 | * Set column and relative value |
||
1184 | * Used in: INSERT, REPLACE |
||
1185 | * |
||
1186 | * @param string $column The column name |
||
1187 | * @param string $value The value |
||
1188 | * |
||
1189 | * @return SphinxQL |
||
1190 | */ |
||
1191 | public function value($column, $value) |
||
1202 | |||
1203 | /** |
||
1204 | * Allows passing an array with the key as column and value as value |
||
1205 | * Used in: INSERT, REPLACE, UPDATE |
||
1206 | * |
||
1207 | * @param array $array Array of key-values |
||
1208 | * |
||
1209 | * @return SphinxQL |
||
1210 | */ |
||
1211 | public function set($array) |
||
1223 | |||
1224 | /** |
||
1225 | * Allows passing an array with the key as column and value as value |
||
1226 | * Used in: INSERT, REPLACE, UPDATE |
||
1227 | * |
||
1228 | * @param Facet $facet |
||
1229 | * @return SphinxQL |
||
1230 | */ |
||
1231 | public function facet($facet) |
||
1237 | |||
1238 | /** |
||
1239 | * Sets the characters used for escapeMatch(). |
||
1240 | * |
||
1241 | * @param array $array The array of characters to escape |
||
1242 | * |
||
1243 | * @return SphinxQL The escaped characters |
||
1244 | */ |
||
1245 | public function setFullEscapeChars($array = array()) |
||
1253 | |||
1254 | /** |
||
1255 | * Sets the characters used for halfEscapeMatch(). |
||
1256 | * |
||
1257 | * @param array $array The array of characters to escape |
||
1258 | * |
||
1259 | * @return SphinxQL The escaped characters |
||
1260 | */ |
||
1261 | public function setHalfEscapeChars($array = array()) |
||
1269 | |||
1270 | /** |
||
1271 | * Compiles an array containing the characters and escaped characters into a key/value configuration. |
||
1272 | * |
||
1273 | * @param array $array The array of characters to escape |
||
1274 | * |
||
1275 | * @return array An array of the characters and it's escaped counterpart |
||
1276 | */ |
||
1277 | public function compileEscapeChars($array = array()) |
||
1286 | |||
1287 | /** |
||
1288 | * Escapes the query for the MATCH() function |
||
1289 | * |
||
1290 | * @param string $string The string to escape for the MATCH |
||
1291 | * |
||
1292 | * @return string The escaped string |
||
1293 | */ |
||
1294 | public function escapeMatch($string) |
||
1302 | |||
1303 | /** |
||
1304 | * Escapes the query for the MATCH() function |
||
1305 | * Allows some of the control characters to pass through for use with a search field: -, |, " |
||
1306 | * It also does some tricks to wrap/unwrap within " the string and prevents errors |
||
1307 | * |
||
1308 | * @param string $string The string to escape for the MATCH |
||
1309 | * |
||
1310 | * @return string The escaped string |
||
1311 | */ |
||
1312 | public function halfEscapeMatch($string) |
||
1338 | |||
1339 | /** |
||
1340 | * Clears the existing query build for new query when using the same SphinxQL instance. |
||
1341 | * |
||
1342 | * @return SphinxQL |
||
1343 | */ |
||
1344 | public function reset() |
||
1365 | |||
1366 | public function resetWhere() |
||
1372 | |||
1373 | public function resetMatch() |
||
1379 | |||
1380 | public function resetGroupBy() |
||
1386 | |||
1387 | public function resetWithinGroupOrderBy() |
||
1393 | |||
1394 | public function resetHaving() |
||
1400 | |||
1401 | public function resetOrderBy() |
||
1407 | |||
1408 | public function resetOptions() |
||
1414 | } |
||
1415 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.