[BUGFIX] Fix usage of preparedStatement object in $query->statement
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / Qom / QueryObjectModelFactory.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Qom;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
8 * Extbase is a backport of TYPO3 Flow. All credits go to the TYPO3 Flow team.
9 * All rights reserved
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 * A copy is found in the text file GPL.txt and important notices to the license
20 * from the author is found in LICENSE.txt distributed with these scripts.
21 *
22 *
23 * This script is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /**
31 * The Query Object Model Factory
32 */
33 class QueryObjectModelFactory implements \TYPO3\CMS\Core\SingletonInterface {
34
35 /**
36 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
37 * @inject
38 */
39 protected $objectManager;
40
41 /**
42 * Selects a subset of the nodes in the repository based on node type.
43 *
44 * @param string $nodeTypeName the name of the required node type; non-null
45 * @param string $selectorName the selector name; optional
46 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SelectorInterface the selector
47 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
48 */
49 public function selector($nodeTypeName, $selectorName = '') {
50 if ($selectorName === '') {
51 $selectorName = $nodeTypeName;
52 }
53 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Selector', $selectorName, $nodeTypeName);
54 }
55
56 /**
57 * Sets a statement as constraint. This is not part of the JCR 2.0 Specification!
58 *
59 * @param string|\TYPO3\CMS\Core\Database\PreparedStatement $statement The statement
60 * @param array $boundVariables An array of variables to bind to the statement
61 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
62 */
63 public function statement($statement, array $boundVariables = array()) {
64 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Statement', $statement, $boundVariables);
65 }
66
67 /**
68 * Performs a join between two node-tuple sources.
69 *
70 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $left the left node-tuple source; non-null
71 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $right the right node-tuple source; non-null
72 * @param string $joinType one of QueryObjectModelConstants.JCR_JOIN_TYPE_*
73 * @param JoinConditionInterface $joinCondition
74 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\JoinInterface the join; non-null
75 */
76 public function join(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $left, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $right, $joinType, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\JoinConditionInterface $joinCondition) {
77 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Join', $left, $right, $joinType, $joinCondition);
78 }
79
80 /**
81 * Tests whether the value of a property in a first selector is equal to the value of a property in a second selector.
82 *
83 * @param string $selector1Name the name of the first selector; non-null
84 * @param string $property1Name the property name in the first selector; non-null
85 * @param string $selector2Name the name of the second selector; non-null
86 * @param string $property2Name the property name in the second selector; non-null
87 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\EquiJoinConditionInterface the constraint; non-null
88 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
89 */
90 public function equiJoinCondition($selector1Name, $property1Name, $selector2Name, $property2Name) {
91 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\EquiJoinCondition', $selector1Name, $property1Name, $selector2Name, $property2Name);
92 }
93
94 /**
95 * Performs a logical conjunction of two other constraints.
96 *
97 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1 the first constraint; non-null
98 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2 the second constraint; non-null
99 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface the And constraint; non-null
100 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
101 */
102 public function _and(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2) {
103 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LogicalAnd', $constraint1, $constraint2);
104 }
105
106 /**
107 * Performs a logical disjunction of two other constraints.
108 *
109 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1 the first constraint; non-null
110 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2 the second constraint; non-null
111 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface the Or constraint; non-null
112 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
113 */
114 public function _or(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint1, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint2) {
115 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LogicalOr', $constraint1, $constraint2);
116 }
117
118 /**
119 * Performs a logical negation of another constraint.
120 *
121 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint the constraint to be negated; non-null
122 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface the Not constraint; non-null
123 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
124 */
125 public function not(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint) {
126 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LogicalNot', $constraint);
127 }
128
129 /**
130 * Filters node-tuples based on the outcome of a binary operation.
131 *
132 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1 the first operand; non-null
133 * @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_*
134 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\StaticOperandInterface $operand2 the second operand; non-null
135 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface the constraint; non-null
136 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
137 */
138 public function comparison(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand1, $operator, $operand2) {
139 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Comparison', $operand1, $operator, $operand2);
140 }
141
142 /**
143 * Evaluates to the value (or values, if multi-valued) of a property in the specified or default selector.
144 *
145 * @param string $propertyName the property name; non-null
146 * @param string $selectorName the selector name; non-null
147 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\PropertyValueInterface the operand; non-null
148 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
149 */
150 public function propertyValue($propertyName, $selectorName = '') {
151 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\PropertyValue', $propertyName, $selectorName);
152 }
153
154 /**
155 * Evaluates to the lower-case string value (or values, if multi-valued) of an operand.
156 *
157 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand whose value is converted to a lower-case string; non-null
158 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\LowerCaseInterface the operand; non-null
159 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
160 */
161 public function lowerCase(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
162 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\LowerCase', $operand);
163 }
164
165 /**
166 * Evaluates to the upper-case string value (or values, if multi-valued) of an operand.
167 *
168 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand whose value is converted to a upper-case string; non-null
169 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\UpperCaseInterface the operand; non-null
170 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
171 */
172 public function upperCase(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
173 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\UpperCase', $operand);
174 }
175
176 /**
177 * Orders by the value of the specified operand, in ascending order.
178 *
179 * The query is invalid if $operand does not evaluate to a scalar value.
180 *
181 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand by which to order; non-null
182 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrderingInterface the ordering
183 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
184 */
185 public function ascending(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
186 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Ordering', $operand, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface::JCR_ORDER_ASCENDING);
187 }
188
189 /**
190 * Orders by the value of the specified operand, in descending order.
191 *
192 * The query is invalid if $operand does not evaluate to a scalar value.
193 *
194 * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand the operand by which to order; non-null
195 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrderingInterface the ordering
196 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
197 */
198 public function descending(\TYPO3\CMS\Extbase\Persistence\Generic\Qom\DynamicOperandInterface $operand) {
199 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\Ordering', $operand, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelConstantsInterface::JCR_ORDER_DESCENDING);
200 }
201
202 /**
203 * Evaluates to the value of a bind variable.
204 *
205 * @param string $bindVariableName the bind variable name; non-null
206 * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\BindVariableValueInterface the operand; non-null
207 * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\RepositoryException if the operation otherwise fails
208 */
209 public function bindVariable($bindVariableName) {
210 return $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Qom\\BindVariableValue', $bindVariableName);
211 }
212 }