3936125ec76e637fe96bc1a3069e90d2ec1ed0ea
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / QueryInterface.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence;
3
4 /* *
5 * This script belongs to the Extbase framework. *
6 * *
7 * This class is a backport of the corresponding class of FLOW3. *
8 * All credits go to the v5 team. *
9 * *
10 * It is free software; you can redistribute it and/or modify it under *
11 * the terms of the GNU Lesser General Public License, either version 3 *
12 * of the License, or (at your option) any later version. *
13 * *
14 * The TYPO3 project - inspiring people to share! *
15 * */
16 /**
17 * A persistence query interface
18 *
19 * @api
20 */
21 interface QueryInterface {
22 /**
23 * The '=' comparison operator.
24 *
25 * @api
26 */
27 const OPERATOR_EQUAL_TO = 1;
28 /**
29 * The '!=' comparison operator.
30 *
31 * @api
32 */
33 const OPERATOR_NOT_EQUAL_TO = 2;
34 /**
35 * The '<' comparison operator.
36 *
37 * @api
38 */
39 const OPERATOR_LESS_THAN = 3;
40 /**
41 * The '<=' comparison operator.
42 *
43 * @api
44 */
45 const OPERATOR_LESS_THAN_OR_EQUAL_TO = 4;
46 /**
47 * The '>' comparison operator.
48 *
49 * @api
50 */
51 const OPERATOR_GREATER_THAN = 5;
52 /**
53 * The '>=' comparison operator.
54 *
55 * @api
56 */
57 const OPERATOR_GREATER_THAN_OR_EQUAL_TO = 6;
58 /**
59 * The 'like' comparison operator.
60 *
61 * @api
62 */
63 const OPERATOR_LIKE = 7;
64 /**
65 * The 'contains' comparison operator.
66 *
67 * @api
68 */
69 const OPERATOR_CONTAINS = 8;
70 /**
71 * The 'in' comparison operator.
72 *
73 * @api
74 */
75 const OPERATOR_IN = 9;
76 /**
77 * Constants representing the direction when ordering result sets.
78 */
79 const ORDER_ASCENDING = 'ASC';
80 const ORDER_DESCENDING = 'DESC';
81 /**
82 * An inner join.
83 */
84 const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
85 /**
86 * A left-outer join.
87 */
88 const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
89 /**
90 * A right-outer join.
91 */
92 const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
93 /**
94 * Charset of strings in QOM
95 */
96 const CHARSET = 'utf-8';
97 /**
98 * Gets the node-tuple source for this query.
99 *
100 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface the node-tuple source; non-NULL
101 */
102 public function getSource();
103
104 /**
105 * Executes the query against the backend and returns the result
106 *
107 * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
108 * @api
109 */
110 public function execute();
111
112 /**
113 * Sets the property names to order the result by. Expected like this:
114 * array(
115 * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
116 * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
117 * )
118 *
119 * @param array $orderings The property names to order by
120 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
121 * @api
122 */
123 public function setOrderings(array $orderings);
124
125 /**
126 * Sets the maximum size of the result set to limit. Returns $this to allow
127 * for chaining (fluid interface)
128 *
129 * @param integer $limit
130 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
131 * @api
132 */
133 public function setLimit($limit);
134
135 /**
136 * Sets the start offset of the result set to offset. Returns $this to
137 * allow for chaining (fluid interface)
138 *
139 * @param integer $offset
140 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
141 * @api
142 */
143 public function setOffset($offset);
144
145 /**
146 * The constraint used to limit the result set. Returns $this to allow
147 * for chaining (fluid interface)
148 *
149 * @param object $constraint Some constraint, depending on the backend
150 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
151 * @api
152 */
153 public function matching($constraint);
154
155 /**
156 * Performs a logical conjunction of the two given constraints.
157 *
158 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
159 * @return object
160 * @api
161 */
162 public function logicalAnd($constraint1);
163
164 /**
165 * Performs a logical disjunction of the two given constraints
166 *
167 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
168 * @return object
169 * @api
170 */
171 public function logicalOr($constraint1);
172
173 /**
174 * Performs a logical negation of the given constraint
175 *
176 * @param object $constraint Constraint to negate
177 * @return object
178 * @api
179 */
180 public function logicalNot($constraint);
181
182 /**
183 * Returns an equals criterion used for matching objects against a query
184 *
185 * @param string $propertyName The name of the property to compare against
186 * @param mixed $operand The value to compare with
187 * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
188 * @return object
189 * @api
190 */
191 public function equals($propertyName, $operand, $caseSensitive = TRUE);
192
193 /**
194 * Returns a like criterion used for matching objects against a query
195 *
196 * @param string $propertyName The name of the property to compare against
197 * @param mixed $operand The value to compare with
198 * @return object
199 * @api
200 */
201 public function like($propertyName, $operand);
202
203 /**
204 * Returns a "contains" criterion used for matching objects against a query.
205 * It matches if the multivalued property contains the given operand.
206 *
207 * @param string $propertyName The name of the (multivalued) property to compare against
208 * @param mixed $operand The value to compare with
209 * @return object
210 * @api
211 */
212 public function contains($propertyName, $operand);
213
214 /**
215 * Returns an "in" criterion used for matching objects against a query. It
216 * matches if the property's value is contained in the multivalued operand.
217 *
218 * @param string $propertyName The name of the property to compare against
219 * @param mixed $operand The value to compare with, multivalued
220 * @return object
221 * @api
222 */
223 public function in($propertyName, $operand);
224
225 /**
226 * Returns a less than criterion used for matching objects against a query
227 *
228 * @param string $propertyName The name of the property to compare against
229 * @param mixed $operand The value to compare with
230 * @return object
231 * @api
232 */
233 public function lessThan($propertyName, $operand);
234
235 /**
236 * Returns a less or equal than criterion used for matching objects against a query
237 *
238 * @param string $propertyName The name of the property to compare against
239 * @param mixed $operand The value to compare with
240 * @return object
241 * @api
242 */
243 public function lessThanOrEqual($propertyName, $operand);
244
245 /**
246 * Returns a greater than criterion used for matching objects against a query
247 *
248 * @param string $propertyName The name of the property to compare against
249 * @param mixed $operand The value to compare with
250 * @return object
251 * @api
252 */
253 public function greaterThan($propertyName, $operand);
254
255 /**
256 * Returns a greater than or equal criterion used for matching objects against a query
257 *
258 * @param string $propertyName The name of the property to compare against
259 * @param mixed $operand The value to compare with
260 * @return object
261 * @api
262 */
263 public function greaterThanOrEqual($propertyName, $operand);
264
265 /**
266 * Returns the type this query cares for.
267 *
268 * @return string
269 * @api
270 */
271 public function getType();
272
273 /**
274 * Sets the Query Settings. These Query settings must match the settings expected by
275 * the specific Storage Backend.
276 *
277 * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
278 * @return void
279 * @api This method is not part of FLOW3 API
280 */
281 public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings);
282
283 /**
284 * Returns the Query Settings.
285 *
286 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
287 * @api This method is not part of FLOW3 API
288 */
289 public function getQuerySettings();
290
291 }
292
293 ?>