QueryInterface.php 8.12 KB
Newer Older
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
1
<?php
Thomas Maroschik's avatar
Thomas Maroschik committed
2
3
namespace TYPO3\CMS\Extbase\Persistence;

4
5
6
7
8
9
10
11
12
13
14
15
/*                                                                        *
 * This script belongs to the Extbase framework.                          *
 *                                                                        *
 * This class is a backport of the corresponding class of FLOW3.          *
 * All credits go to the v5 team.                                         *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 * of the License, or (at your option) any later version.                 *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
16
17
18
/**
 * A persistence query interface
 *
19
20
 * @package Extbase
 * @subpackage Persistence
21
 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
22
 */
Thomas Maroschik's avatar
Thomas Maroschik committed
23
interface QueryInterface
24
{
25
26
	/**
	 * The '=' comparison operator.
27
	 *
28
	 * @api
29
	 */
30
31
32
	const OPERATOR_EQUAL_TO = 1;
	/**
	 * The '!=' comparison operator.
33
	 *
34
	 * @api
35
	 */
36
37
38
	const OPERATOR_NOT_EQUAL_TO = 2;
	/**
	 * The '<' comparison operator.
39
	 *
40
	 * @api
41
	 */
42
43
44
	const OPERATOR_LESS_THAN = 3;
	/**
	 * The '<=' comparison operator.
45
	 *
46
	 * @api
47
	 */
48
49
50
	const OPERATOR_LESS_THAN_OR_EQUAL_TO = 4;
	/**
	 * The '>' comparison operator.
51
	 *
52
	 * @api
53
	 */
54
55
56
	const OPERATOR_GREATER_THAN = 5;
	/**
	 * The '>=' comparison operator.
57
	 *
58
	 * @api
59
	 */
60
61
62
	const OPERATOR_GREATER_THAN_OR_EQUAL_TO = 6;
	/**
	 * The 'like' comparison operator.
63
	 *
64
	 * @api
65
	 */
66
67
68
	const OPERATOR_LIKE = 7;
	/**
	 * The 'contains' comparison operator.
69
	 *
70
	 * @api
71
	 */
72
73
74
	const OPERATOR_CONTAINS = 8;
	/**
	 * The 'in' comparison operator.
75
	 *
76
	 * @api
77
	 */
78
	const OPERATOR_IN = 9;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
79
80
81
82
83
	/**
	 * Constants representing the direction when ordering result sets.
	 */
	const ORDER_ASCENDING = 'ASC';
	const ORDER_DESCENDING = 'DESC';
84
85
86
87
88
89
90
91
92
93
94
95
	/**
	 * An inner join.
	 */
	const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
	/**
	 * A left-outer join.
	 */
	const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
	/**
	 * A right-outer join.
	 */
	const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
96
97
98
99
	/**
	 * Charset of strings in QOM
	 */
	const CHARSET = 'utf-8';
100
101
102
	/**
	 * Gets the node-tuple source for this query.
	 *
Thomas Maroschik's avatar
Thomas Maroschik committed
103
	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface the node-tuple source; non-NULL
104
105
106
	 */
	public function getSource();

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
107
108
109
	/**
	 * Executes the query against the backend and returns the result
	 *
110
	 * @return Tx_Extbase_Persistence_QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
111
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
112
113
114
115
116
117
	 */
	public function execute();

	/**
	 * Sets the property names to order the result by. Expected like this:
	 * array(
118
119
	 * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
	 * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
120
121
122
	 * )
	 *
	 * @param array $orderings The property names to order by
Thomas Maroschik's avatar
Thomas Maroschik committed
123
	 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
124
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
125
126
127
128
129
130
131
132
	 */
	public function setOrderings(array $orderings);

	/**
	 * Sets the maximum size of the result set to limit. Returns $this to allow
	 * for chaining (fluid interface)
	 *
	 * @param integer $limit
Thomas Maroschik's avatar
Thomas Maroschik committed
133
	 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
134
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
135
136
137
138
139
140
141
142
	 */
	public function setLimit($limit);

	/**
	 * Sets the start offset of the result set to offset. Returns $this to
	 * allow for chaining (fluid interface)
	 *
	 * @param integer $offset
Thomas Maroschik's avatar
Thomas Maroschik committed
143
	 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
144
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
145
146
147
148
149
150
151
152
	 */
	public function setOffset($offset);

	/**
	 * The constraint used to limit the result set. Returns $this to allow
	 * for chaining (fluid interface)
	 *
	 * @param object $constraint Some constraint, depending on the backend
Thomas Maroschik's avatar
Thomas Maroschik committed
153
	 * @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
154
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
155
156
157
158
159
160
	 */
	public function matching($constraint);

	/**
	 * Performs a logical conjunction of the two given constraints.
	 *
161
	 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
162
	 * @return object
163
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
164
	 */
165
	public function logicalAnd($constraint1);
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
166
167
168
169

	/**
	 * Performs a logical disjunction of the two given constraints
	 *
170
	 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
171
	 * @return object
172
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
173
	 */
174
	public function logicalOr($constraint1);
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
175
176
177
178
179
180

	/**
	 * Performs a logical negation of the given constraint
	 *
	 * @param object $constraint Constraint to negate
	 * @return object
181
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
182
183
184
185
186
187
188
189
190
191
	 */
	public function logicalNot($constraint);

	/**
	 * Returns an equals criterion used for matching objects against a query
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with
	 * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
	 * @return object
192
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
193
194
195
196
197
198
199
200
201
	 */
	public function equals($propertyName, $operand, $caseSensitive = TRUE);

	/**
	 * Returns a like criterion used for matching objects against a query
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with
	 * @return object
202
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
203
204
205
	 */
	public function like($propertyName, $operand);

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
	/**
	 * Returns a "contains" criterion used for matching objects against a query.
	 * It matches if the multivalued property contains the given operand.
	 *
	 * @param string $propertyName The name of the (multivalued) property to compare against
	 * @param mixed $operand The value to compare with
	 * @return object
	 * @api
	 */
	public function contains($propertyName, $operand);

	/**
	 * Returns an "in" criterion used for matching objects against a query. It
	 * matches if the property's value is contained in the multivalued operand.
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with, multivalued
	 * @return object
	 * @api
	 */
	public function in($propertyName, $operand);

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
228
229
230
231
232
233
	/**
	 * Returns a less than criterion used for matching objects against a query
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with
	 * @return object
234
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
235
236
237
238
239
240
241
242
243
	 */
	public function lessThan($propertyName, $operand);

	/**
	 * Returns a less or equal than criterion used for matching objects against a query
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with
	 * @return object
244
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
245
246
247
248
249
250
251
252
253
	 */
	public function lessThanOrEqual($propertyName, $operand);

	/**
	 * Returns a greater than criterion used for matching objects against a query
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with
	 * @return object
254
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
255
256
257
258
259
260
261
262
263
	 */
	public function greaterThan($propertyName, $operand);

	/**
	 * Returns a greater than or equal criterion used for matching objects against a query
	 *
	 * @param string $propertyName The name of the property to compare against
	 * @param mixed $operand The value to compare with
	 * @return object
264
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
265
266
267
	 */
	public function greaterThanOrEqual($propertyName, $operand);

268
269
270
271
272
273
274
275
276
277
278
279
	/**
	 * Returns the type this query cares for.
	 *
	 * @return string
	 * @api
	 */
	public function getType();

	/**
	 * Sets the Query Settings. These Query settings must match the settings expected by
	 * the specific Storage Backend.
	 *
Thomas Maroschik's avatar
Thomas Maroschik committed
280
	 * @param \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
281
282
283
	 * @return void
	 * @api This method is not part of FLOW3 API
	 */
Thomas Maroschik's avatar
Thomas Maroschik committed
284
	public function setQuerySettings(\TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings);
285
286
287
288

	/**
	 * Returns the Query Settings.
	 *
Thomas Maroschik's avatar
Thomas Maroschik committed
289
	 * @return \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface $querySettings The Query Settings
290
291
292
	 * @api This method is not part of FLOW3 API
	 */
	public function getQuerySettings();
293

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
294
}
Thomas Maroschik's avatar
Thomas Maroschik committed
295

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
296
?>