2 /***************************************************************
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * A persistence query interface
32 * @subpackage Persistence
36 interface Tx_Extbase_Persistence_QueryInterface
{
39 * The '=' comparison operator.
42 const OPERATOR_EQUAL_TO
= 1;
45 * The '!=' comparison operator.
48 const OPERATOR_NOT_EQUAL_TO
= 2;
51 * The '<' comparison operator.
54 const OPERATOR_LESS_THAN
= 3;
57 * The '<=' comparison operator.
60 const OPERATOR_LESS_THAN_OR_EQUAL_TO
= 4;
63 * The '>' comparison operator.
66 const OPERATOR_GREATER_THAN
= 5;
69 * The '>=' comparison operator.
72 const OPERATOR_GREATER_THAN_OR_EQUAL_TO
= 6;
75 * The 'like' comparison operator.
78 const OPERATOR_LIKE
= 7;
81 * The 'contains' comparison operator.
84 const OPERATOR_CONTAINS
= 8;
87 * The 'in' comparison operator.
90 const OPERATOR_IN
= 9;
93 * Constants representing the direction when ordering result sets.
95 const ORDER_ASCENDING
= 'ASC';
96 const ORDER_DESCENDING
= 'DESC';
101 const JCR_JOIN_TYPE_INNER
= '{http://www.jcp.org/jcr/1.0}joinTypeInner';
106 const JCR_JOIN_TYPE_LEFT_OUTER
= '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
109 * A right-outer join.
111 const JCR_JOIN_TYPE_RIGHT_OUTER
= '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
114 * Executes the query against the backend and returns the result
116 * @return Tx_Extbase_Persistence_QueryResultInterface|array The query result object or an array if $this->getQuerySettings()->getReturnRawQueryResult() is TRUE
119 public function execute();
122 * Executes the query against the database and returns the number of matching objects
124 * @return integer The number of matching objects
125 * @deprecated since Extbase 1.3.0; was removed in FLOW3; will be removed in Extbase 1.5.0
127 public function count();
130 * Sets the property names to order the result by. Expected like this:
132 * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
133 * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
136 * @param array $orderings The property names to order by
137 * @return Tx_Extbase_Persistence_QueryInterface
140 public function setOrderings(array $orderings);
143 * Sets the maximum size of the result set to limit. Returns $this to allow
144 * for chaining (fluid interface)
146 * @param integer $limit
147 * @return Tx_Extbase_Persistence_QueryInterface
150 public function setLimit($limit);
153 * Sets the start offset of the result set to offset. Returns $this to
154 * allow for chaining (fluid interface)
156 * @param integer $offset
157 * @return Tx_Extbase_Persistence_QueryInterface
160 public function setOffset($offset);
163 * The constraint used to limit the result set. Returns $this to allow
164 * for chaining (fluid interface)
166 * @param object $constraint Some constraint, depending on the backend
167 * @return Tx_Extbase_Persistence_QueryInterface
170 public function matching($constraint);
173 * Performs a logical conjunction of the two given constraints.
175 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
179 public function logicalAnd($constraint1);
182 * Performs a logical disjunction of the two given constraints
184 * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
188 public function logicalOr($constraint1);
191 * Performs a logical negation of the given constraint
193 * @param object $constraint Constraint to negate
197 public function logicalNot($constraint);
200 * Returns an equals criterion used for matching objects against a query
202 * @param string $propertyName The name of the property to compare against
203 * @param mixed $operand The value to compare with
204 * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
208 public function equals($propertyName, $operand, $caseSensitive = TRUE
);
211 * Returns a like criterion used for matching objects against a query
213 * @param string $propertyName The name of the property to compare against
214 * @param mixed $operand The value to compare with
218 public function like($propertyName, $operand);
221 * Returns a "contains" criterion used for matching objects against a query.
222 * It matches if the multivalued property contains the given operand.
224 * @param string $propertyName The name of the (multivalued) property to compare against
225 * @param mixed $operand The value to compare with
229 public function contains($propertyName, $operand);
232 * Returns an "in" criterion used for matching objects against a query. It
233 * matches if the property's value is contained in the multivalued operand.
235 * @param string $propertyName The name of the property to compare against
236 * @param mixed $operand The value to compare with, multivalued
240 public function in($propertyName, $operand);
243 * Returns a less than criterion used for matching objects against a query
245 * @param string $propertyName The name of the property to compare against
246 * @param mixed $operand The value to compare with
250 public function lessThan($propertyName, $operand);
253 * Returns a less or equal than criterion used for matching objects against a query
255 * @param string $propertyName The name of the property to compare against
256 * @param mixed $operand The value to compare with
260 public function lessThanOrEqual($propertyName, $operand);
263 * Returns a greater than criterion used for matching objects against a query
265 * @param string $propertyName The name of the property to compare against
266 * @param mixed $operand The value to compare with
270 public function greaterThan($propertyName, $operand);
273 * Returns a greater than or equal criterion used for matching objects against a query
275 * @param string $propertyName The name of the property to compare against
276 * @param mixed $operand The value to compare with
280 public function greaterThanOrEqual($propertyName, $operand);
283 * Returns the type this query cares for.
288 public function getType();
291 * Sets the Query Settings. These Query settings must match the settings expected by
292 * the specific Storage Backend.
294 * @param Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
296 * @api This method is not part of FLOW3 API
298 public function setQuerySettings(Tx_Extbase_Persistence_QuerySettingsInterface
$querySettings);
301 * Returns the Query Settings.
303 * @return Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
304 * @api This method is not part of FLOW3 API
306 public function getQuerySettings();