QueryInterface.php 5.63 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
38
39
40
41
42
43
44
45
46
 */
interface Tx_Extbase_Persistence_QueryInterface {

	/**
	 * Constants representing the direction when ordering result sets.
	 */
	const ORDER_ASCENDING = 'ASC';
	const ORDER_DESCENDING = 'DESC';

	/**
	 * Executes the query against the backend and returns the result
	 *
47
48
	 * @return array<object> The query result as an array of objects
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
49
50
51
	 */
	public function execute();

52
53
54
55
56
57
58
59
	/**
	 * Executes the query against the database and returns the number of matching objects
	 *
	 * @return integer The number of matching objects
	 * @api
	 */
	public function count();

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
60
61
62
63
64
65
66
67
68
	/**
	 * 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
69
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
70
71
72
73
74
75
76
77
78
	 */
	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
79
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
80
81
82
83
84
85
86
87
88
	 */
	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
89
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
90
91
92
93
94
95
96
97
98
	 */
	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
99
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
100
101
102
103
104
105
106
107
108
	 */
	public function matching($constraint);

	/**
	 * Performs a logical conjunction of the two given constraints.
	 *
	 * @param object $constraint1 First constraint
	 * @param object $constraint2 Second constraint
	 * @return object
109
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
110
111
112
113
114
115
116
117
118
	 */
	public function logicalAnd($constraint1, $constraint2);

	/**
	 * Performs a logical disjunction of the two given constraints
	 *
	 * @param object $constraint1 First constraint
	 * @param object $constraint2 Second constraint
	 * @return object
119
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
120
121
122
123
124
125
126
127
	 */
	public function logicalOr($constraint1, $constraint2);

	/**
	 * Performs a logical negation of the given constraint
	 *
	 * @param object $constraint Constraint to negate
	 * @return object
128
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
129
130
131
132
133
134
135
136
	 */
	public function logicalNot($constraint);

	/**
	 * Matches against the (internal) identifier.
	 *
	 * @param string $uid An identifier to match against
	 * @return object
137
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
138
139
140
141
142
143
144
145
146
147
	 */
	public function withUid($uid);

	/**
	 * 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
148
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
149
150
151
152
153
154
155
156
157
	 */
	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
158
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
159
160
161
162
163
164
165
166
167
	 */
	public function like($propertyName, $operand);

	/**
	 * 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
168
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
169
170
171
172
173
174
175
176
177
	 */
	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
178
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
179
180
181
182
183
184
185
186
187
	 */
	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
188
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
189
190
191
192
193
194
195
196
197
	 */
	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
198
	 * @api
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
199
200
201
202
203
	 */
	public function greaterThanOrEqual($propertyName, $operand);

}
?>