QueryInterface.php 8.32 KB
Newer Older
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
1
2
3
4
5
6
7
<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
*  All rights reserved
*
8
*  This class is a backport of the corresponding class of FLOW3.
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
*  All credits go to the v5 team.
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

/**
 * A persistence query interface
 *
31
32
 * @package Extbase
 * @subpackage Persistence
33
 * @version $Id$
34
 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
35
36
37
 */
interface Tx_Extbase_Persistence_QueryInterface {

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
	/**
	 * The '=' comparison operator.
	 * @api
	*/
	const OPERATOR_EQUAL_TO = 1;

	/**
	 * The '!=' comparison operator.
	 * @api
	*/
	const OPERATOR_NOT_EQUAL_TO = 2;

	/**
	 * The '<' comparison operator.
	 * @api
	*/
	const OPERATOR_LESS_THAN = 3;

	/**
	 * The '<=' comparison operator.
	 * @api
	*/
	const OPERATOR_LESS_THAN_OR_EQUAL_TO = 4;

	/**
	 * The '>' comparison operator.
	 * @api
	*/
	const OPERATOR_GREATER_THAN = 5;

	/**
	 * The '>=' comparison operator.
	 * @api
	*/
	const OPERATOR_GREATER_THAN_OR_EQUAL_TO = 6;

	/**
	 * The 'like' comparison operator.
	 * @api
	*/
	const OPERATOR_LIKE = 7;

	/**
	 * The 'contains' comparison operator.
	 * @api
	*/
	const OPERATOR_CONTAINS = 8;

	/**
	 * The 'in' comparison operator.
	 * @api
	*/
	const OPERATOR_IN = 9;

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
92
93
94
95
96
97
	/**
	 * Constants representing the direction when ordering result sets.
	 */
	const ORDER_ASCENDING = 'ASC';
	const ORDER_DESCENDING = 'DESC';

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
	/**
	 * 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';

113
114
115
116
117
118
119
	/**
	 * Gets the node-tuple source for this query.
	 *
	 * @return Tx_Extbase_Persistence_QOM_SourceInterface the node-tuple source; non-NULL
	 */
	public function getSource();

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
120
121
122
	/**
	 * Executes the query against the backend and returns the result
	 *
123
	 * @return Tx_Extbase_Persistence_QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
124
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
125
126
127
	 */
	public function execute();

128
129
130
131
	/**
	 * Executes the query against the database and returns the number of matching objects
	 *
	 * @return integer The number of matching objects
132
	 * @deprecated since Extbase 1.3.0; was removed in FLOW3; will be removed in Extbase 1.5.0
133
134
135
	 */
	public function count();

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
136
137
138
139
140
141
142
143
144
	/**
	 * Sets the property names to order the result by. Expected like this:
	 * array(
	 *  'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
	 *  'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
	 * )
	 *
	 * @param array $orderings The property names to order by
	 * @return Tx_Extbase_Persistence_QueryInterface
145
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
146
147
148
149
150
151
152
153
154
	 */
	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
	 * @return Tx_Extbase_Persistence_QueryInterface
155
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
156
157
158
159
160
161
162
163
164
	 */
	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
	 * @return Tx_Extbase_Persistence_QueryInterface
165
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
166
167
168
169
170
171
172
173
174
	 */
	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
	 * @return Tx_Extbase_Persistence_QueryInterface
175
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
176
177
178
179
180
181
	 */
	public function matching($constraint);

	/**
	 * Performs a logical conjunction of the two given constraints.
	 *
182
	 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
183
	 * @return object
184
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
185
	 */
186
	public function logicalAnd($constraint1);
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
187
188
189
190

	/**
	 * Performs a logical disjunction of the two given constraints
	 *
191
	 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
192
	 * @return object
193
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
194
	 */
195
	public function logicalOr($constraint1);
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
196
197
198
199
200
201

	/**
	 * Performs a logical negation of the given constraint
	 *
	 * @param object $constraint Constraint to negate
	 * @return object
202
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
203
204
205
206
207
208
209
210
211
212
	 */
	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
213
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
214
215
216
217
218
219
220
221
222
	 */
	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
223
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
224
225
226
	 */
	public function like($propertyName, $operand);

227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
	/**
	 * 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
249
250
251
252
253
254
	/**
	 * 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
255
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
256
257
258
259
260
261
262
263
264
	 */
	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
265
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
266
267
268
269
270
271
272
273
274
	 */
	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
275
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
276
277
278
279
280
281
282
283
284
	 */
	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
285
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
286
287
288
	 */
	public function greaterThanOrEqual($propertyName, $operand);

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
	/**
	 * 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.
	 *
	 * @param Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
	 * @return void
	 * @api This method is not part of FLOW3 API
	 */
	public function setQuerySettings(Tx_Extbase_Persistence_QuerySettingsInterface $querySettings);

	/**
	 * Returns the Query Settings.
	 *
	 * @return Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
	 * @api This method is not part of FLOW3 API
	 */
	public function getQuerySettings();
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
314
315
}
?>