/
ESphinxQuery.php
69 lines (65 loc) · 1.24 KB
/
ESphinxQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* This file contains filesource of class ESphinxQuery
*/
/**
* Class implements sphinx query model.
* Query contains search text, indexes list, and sphinx criteria.
*/
class ESphinxQuery extends CComponent
{
/**
* @var string $_text
*/
private $_text;
/**
* @var string $_indexes
*/
private $_indexes;
/**
* @var ESphinxCriteria $_criteria
*/
private $_criteria;
/**
* Query constructor.
*
* @param string $text search phrase
* @param string $indexes list of indexes
* @param ESphinxCriteria $criteria search criterias
*/
public function __construct($text, $indexes="*", $criteria = null )
{
$this->_text = (string)$text;
$this->_indexes = (string)$indexes;
if($criteria instanceof ESphinxCriteria )
$this->_criteria = $criteria;
else
$this->_criteria = new ESphinxCriteria;
if(is_array($indexes))
$indexes = join(" ", $indexes);
}
/**
* Get search query
* @return string
*/
public function getText()
{
return $this->_text;
}
/**
* Get list indexes as string
* @return string
*/
public function getIndexes()
{
return $this->_indexes;
}
/**
* Get search criteria
* @return ESphinxCriteria
*/
public function getCriteria()
{
return $this->_criteria;
}
}