1 | <?php |
||
10 | class FilterCondition |
||
11 | { |
||
12 | /** |
||
13 | * Filter types: standard string and numeric comparison. |
||
14 | * This set of comparison methods are understood by any DataSource that wants to be easily swappable |
||
15 | * |
||
16 | * Additional filtering methods may be defined to be consumed by custom data sources. |
||
17 | */ |
||
18 | |||
19 | const METHOD_STRING_EQ = "STRING_EQ"; |
||
20 | const METHOD_STRING_LIKE = "STRING_LIKE"; |
||
21 | const METHOD_STRING_NEQ = "STRING_NEQ"; |
||
22 | const METHOD_NUMERIC_GT = "NUMERIC_GT"; |
||
23 | const METHOD_NUMERIC_GTE = "NUMERIC_GTE"; |
||
24 | const METHOD_NUMERIC_EQ = "NUMERIC_EQ"; |
||
25 | const METHOD_NUMERIC_LTE = "NUMERIC_LTE"; |
||
26 | const METHOD_NUMERIC_LT = "NUMERIC_LT"; |
||
27 | const METHOD_NUMERIC_NEQ = "NUMERIC_NEQ"; |
||
28 | const METHOD_IN = "IN"; |
||
29 | const METHOD_BOOLEAN = "BOOLEAN"; |
||
30 | const METHOD_IS_NULL = "IS_NULL"; |
||
31 | const METHOD_DATETIME_GT = "DATETIME_GT"; |
||
32 | const METHOD_DATETIME_GTE = "DATETIME_GTE"; |
||
33 | const METHOD_DATETIME_EQ = "DATETIME_EQ"; |
||
34 | const METHOD_DATETIME_LTE = "DATETIME_LTE"; |
||
35 | const METHOD_DATETIME_LT = "DATETIME_LT"; |
||
36 | const METHOD_DATETIME_NEQ = "DATETIME_NEQ"; |
||
37 | |||
38 | /** |
||
39 | * Column ID to filter by |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $fieldName; |
||
44 | |||
45 | /** |
||
46 | * Filtering method, of those defined in this class' constants |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | private $method; |
||
51 | |||
52 | /** |
||
53 | * A value to filter by |
||
54 | * |
||
55 | * @var mixed |
||
56 | */ |
||
57 | private $value; |
||
58 | |||
59 | /** |
||
60 | * @var mixed |
||
61 | */ |
||
62 | private $valueInDatabase; |
||
63 | |||
64 | /** |
||
65 | * @param $columnIdentifier string The unique identifier of the column to filter by |
||
66 | * @param $method string A value passed to the data source in order to decide how to filter |
||
67 | * @param $value string The value to filter with |
||
68 | * @param $valueInDatabase string The presentation of the filtered value inside the database |
||
69 | */ |
||
70 | public function __construct($columnIdentifier, $method, $value, $valueInDatabase) |
||
77 | |||
78 | /** |
||
79 | * Returns an array serializable to JSON for the compact exchange format. |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | public function toJsonSerializable() |
||
91 | |||
92 | /** |
||
93 | * Get a UQL representation of this filter statement |
||
94 | * |
||
95 | * @return string |
||
96 | */ |
||
97 | public function toUQL() |
||
137 | |||
138 | /** |
||
139 | * @return mixed |
||
140 | */ |
||
141 | public function getValue() |
||
145 | |||
146 | /** |
||
147 | * @param mixed $value |
||
148 | */ |
||
149 | public function setValue($value) |
||
153 | |||
154 | /** |
||
155 | * @return mixed |
||
156 | */ |
||
157 | public function getFieldName() |
||
161 | |||
162 | /** |
||
163 | * @param mixed $fieldName |
||
164 | */ |
||
165 | public function setFieldName($fieldName) |
||
169 | |||
170 | /** |
||
171 | * @return mixed |
||
172 | */ |
||
173 | public function getMethod() |
||
177 | |||
178 | /** |
||
179 | * @param mixed $method |
||
180 | */ |
||
181 | public function setMethod($method) |
||
185 | |||
186 | /** |
||
187 | * @return mixed |
||
188 | */ |
||
189 | public function getValueInDatabase() |
||
193 | |||
194 | /** |
||
195 | * @param mixed $valueInDatabase |
||
196 | */ |
||
197 | public function setValueInDatabase($valueInDatabase) |
||
201 | } |
||
202 |