[~TASK] Extbase (Persistence): Added count() to the QueryInterface. Related to #4991.
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / QueryInterface.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
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.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * A persistence query interface
30 *
31 * @package Extbase
32 * @subpackage Persistence
33 * @version $Id: QueryInterface.php 658 2009-05-16 13:54:16Z jocrau $
34 * @api
35 */
36 interface Tx_Extbase_Persistence_QueryInterface {
37
38 /**
39 * Constants representing the direction when ordering result sets.
40 */
41 const ORDER_ASCENDING = 'ASC';
42 const ORDER_DESCENDING = 'DESC';
43
44 /**
45 * Executes the query against the backend and returns the result
46 *
47 * @return array<object> The query result as an array of objects
48 * @api
49 */
50 public function execute();
51
52 /**
53 * Executes the query against the database and returns the number of matching objects
54 *
55 * @return integer The number of matching objects
56 * @api
57 */
58 public function count();
59
60 /**
61 * Sets the property names to order the result by. Expected like this:
62 * array(
63 * 'foo' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING,
64 * 'bar' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING
65 * )
66 *
67 * @param array $orderings The property names to order by
68 * @return Tx_Extbase_Persistence_QueryInterface
69 * @api
70 */
71 public function setOrderings(array $orderings);
72
73 /**
74 * Sets the maximum size of the result set to limit. Returns $this to allow
75 * for chaining (fluid interface)
76 *
77 * @param integer $limit
78 * @return Tx_Extbase_Persistence_QueryInterface
79 * @api
80 */
81 public function setLimit($limit);
82
83 /**
84 * Sets the start offset of the result set to offset. Returns $this to
85 * allow for chaining (fluid interface)
86 *
87 * @param integer $offset
88 * @return Tx_Extbase_Persistence_QueryInterface
89 * @api
90 */
91 public function setOffset($offset);
92
93 /**
94 * The constraint used to limit the result set. Returns $this to allow
95 * for chaining (fluid interface)
96 *
97 * @param object $constraint Some constraint, depending on the backend
98 * @return Tx_Extbase_Persistence_QueryInterface
99 * @api
100 */
101 public function matching($constraint);
102
103 /**
104 * Performs a logical conjunction of the two given constraints.
105 *
106 * @param object $constraint1 First constraint
107 * @param object $constraint2 Second constraint
108 * @return object
109 * @api
110 */
111 public function logicalAnd($constraint1, $constraint2);
112
113 /**
114 * Performs a logical disjunction of the two given constraints
115 *
116 * @param object $constraint1 First constraint
117 * @param object $constraint2 Second constraint
118 * @return object
119 * @api
120 */
121 public function logicalOr($constraint1, $constraint2);
122
123 /**
124 * Performs a logical negation of the given constraint
125 *
126 * @param object $constraint Constraint to negate
127 * @return object
128 * @api
129 */
130 public function logicalNot($constraint);
131
132 /**
133 * Matches against the (internal) identifier.
134 *
135 * @param string $uid An identifier to match against
136 * @return object
137 * @api
138 */
139 public function withUid($uid);
140
141 /**
142 * Returns an equals criterion used for matching objects against a query
143 *
144 * @param string $propertyName The name of the property to compare against
145 * @param mixed $operand The value to compare with
146 * @param boolean $caseSensitive Whether the equality test should be done case-sensitive
147 * @return object
148 * @api
149 */
150 public function equals($propertyName, $operand, $caseSensitive = TRUE);
151
152 /**
153 * Returns a like criterion used for matching objects against a query
154 *
155 * @param string $propertyName The name of the property to compare against
156 * @param mixed $operand The value to compare with
157 * @return object
158 * @api
159 */
160 public function like($propertyName, $operand);
161
162 /**
163 * Returns a less than criterion used for matching objects against a query
164 *
165 * @param string $propertyName The name of the property to compare against
166 * @param mixed $operand The value to compare with
167 * @return object
168 * @api
169 */
170 public function lessThan($propertyName, $operand);
171
172 /**
173 * Returns a less or equal than criterion used for matching objects against a query
174 *
175 * @param string $propertyName The name of the property to compare against
176 * @param mixed $operand The value to compare with
177 * @return object
178 * @api
179 */
180 public function lessThanOrEqual($propertyName, $operand);
181
182 /**
183 * Returns a greater than 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 * @return object
188 * @api
189 */
190 public function greaterThan($propertyName, $operand);
191
192 /**
193 * Returns a greater than or equal criterion used for matching objects against a query
194 *
195 * @param string $propertyName The name of the property to compare against
196 * @param mixed $operand The value to compare with
197 * @return object
198 * @api
199 */
200 public function greaterThanOrEqual($propertyName, $operand);
201
202 }
203 ?>