[!!!][~API] Extbase (Persistence): $query->execute() now returns a plain array of...
authorJochen Rau <j.rau@web.de>
Mon, 8 Mar 2010 16:59:04 +0000 (16:59 +0000)
committerJochen Rau <j.rau@web.de>
Mon, 8 Mar 2010 16:59:04 +0000 (16:59 +0000)
[~TASK] Extbase (Persistence): Refactored persistence layer (part I). Dropped QueryObjectModel. The Query-Object is now passed directly to the StorageBackend.
[+API] Extbase (Persistence): Implemented methods in() and contains() in the Query-Object. Resolves #6707.
[+FEATURE] Extbase (Persistence): It is now possible to ask contains() for mm-relations, e.g. $query->contains('categories', $category). Resolves #4679.

15 files changed:
typo3/sysext/extbase/Classes/Dispatcher.php
typo3/sysext/extbase/Classes/DomainObject/DomainObjectInterface.php
typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/Manager.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/QOM/Comparison.php
typo3/sysext/extbase/Classes/Persistence/QOM/Constraint.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Persistence/QOM/QueryObjectModelFactory.php
typo3/sysext/extbase/Classes/Persistence/QOM/QueryObjectModelFactoryInterface.php
typo3/sysext/extbase/Classes/Persistence/Query.php
typo3/sysext/extbase/Classes/Persistence/QueryInterface.php
typo3/sysext/extbase/Classes/Persistence/Storage/BackendInterface.php
typo3/sysext/extbase/Classes/Persistence/Storage/Typo3DbBackend.php
typo3/sysext/extbase/Classes/Persistence/Value.php
typo3/sysext/extbase/Tests/Persistence/Storage/Typo3DbBackend_testcase.php

index 37a18a9..d0b6bdf 100644 (file)
@@ -262,10 +262,10 @@ class Tx_Extbase_Dispatcher {
                        $dataMapper->injectIdentityMap($identityMap);
                        $dataMapper->injectSession($persistenceSession);
                        $dataMapper->injectReflectionService(self::$reflectionService);
-
+                       
                        $storageBackend = t3lib_div::makeInstance('Tx_Extbase_Persistence_Storage_Typo3DbBackend', $GLOBALS['TYPO3_DB']); // singleton
                        $storageBackend->injectDataMapper($dataMapper);
-                       
+
                        $qomFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_QueryObjectModelFactory', $storageBackend);
                        
                        $dataMapper->setQomFactory($qomFactory);
index 13d468c..a104723 100644 (file)
 interface Tx_Extbase_DomainObject_DomainObjectInterface {
 
        /**
+        * Getter for uid.
+        *
+        * @return int the uid or NULL if none set yet.
+        */
+       public function getUid();
+
+       /**
         * Register an object's clean state, e.g. after it has been reconstituted
         * from the database
         *
index aa4df57..dc944c5 100644 (file)
@@ -222,6 +222,28 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
        }
 
        /**
+        * Returns the number of records matching the query.
+        *
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return integer
+        * @api
+        */
+       public function getObjectCountByQuery(Tx_Extbase_Persistence_QueryInterface $query) {
+               return $this->storageBackend->getObjectCountByQuery($query);
+       }
+
+       /**
+        * Returns the object data matching the $query.
+        *
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return array
+        * @api
+        */
+       public function getObjectDataByQuery(Tx_Extbase_Persistence_QueryInterface $query) {
+               return $this->storageBackend->getObjectDataByQuery($query);
+       }
+
+       /**
         * Returns the (internal) identifier for the object, if it is known to the
         * backend. Otherwise NULL is returned.
         *
@@ -553,10 +575,9 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                $columnMap = $this->dataMapper->getDataMap($className)->getColumnMap($propertyName);
                $query = $this->queryFactory->create($className);
                $query->getQuerySettings()->setReturnRawQueryResult(TRUE);
-               $result = $query->matching($query->withUid($object->getUid()))->execute();
-               $rows = $result->getRows();
-               $currentRow = current(current($rows));
-               $fieldValue = $currentRow->getValue($columnMap->getColumnName());
+               $rows = $query->matching($query->withUid($object->getUid()))->execute();
+               $currentRow = current($rows);
+               $fieldValue = $currentRow[$columnMap->getColumnName()];
                return $fieldValue;
        }
        
index 7635933..b3d0067 100644 (file)
@@ -124,6 +124,28 @@ class Tx_Extbase_Persistence_Manager implements Tx_Extbase_Persistence_ManagerIn
        public function getRepositoryClassNames() {
                return $this->repositoryClassNames;
        }
+       
+       /**
+        * Returns the number of records matching the query.
+        *
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return integer
+        * @api
+        */
+       public function getObjectCountByQuery(Tx_Extbase_Persistence_QueryInterface $query) {
+               return $this->backend->getObjectCountByQuery($query);
+       }
+
+       /**
+        * Returns the object data matching the $query.
+        *
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return array
+        * @api
+        */
+       public function getObjectDataByQuery(Tx_Extbase_Persistence_QueryInterface $query) {
+               return $this->backend->getObjectDataByQuery($query);
+       }
 
        /**
         * Commits new objects and changes to objects in the current persistence
index 2b740a5..5aeb7ab 100644 (file)
@@ -132,7 +132,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
         * @param Tx_Extbase_Persistence_RowIteratorInterface $rows
         * @return array
         */
-       public function map($className, Tx_Extbase_Persistence_RowIteratorInterface $rows) {
+       public function map($className, ARRAY $rows) {
                $objects = array();
                foreach ($rows as $row) {
                        $objects[] = $this->mapSingleRow($className, $row);
@@ -146,12 +146,12 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
         * @param Tx_Extbase_Persistence_RowInterface $node
         * @return object
         */
-       protected function mapSingleRow($className, Tx_Extbase_Persistence_RowInterface $row) {
-               if ($this->identityMap->hasIdentifier($row->getValue('uid'), $className)) {
-                       $object = $this->identityMap->getObjectByIdentifier($row->getValue('uid'), $className);
+       protected function mapSingleRow($className, array $row) {
+               if ($this->identityMap->hasIdentifier($row['uid'], $className)) {
+                       $object = $this->identityMap->getObjectByIdentifier($row['uid'], $className);
                } else {
                        $object = $this->createEmptyObject($className);
-                       $this->identityMap->registerObject($object, $row->getValue('uid'));
+                       $this->identityMap->registerObject($object, $row['uid']);
                        $this->thawProperties($object, $row);
                        $object->_memorizeCleanState();
                        $this->persistenceSession->registerReconstitutedObject($object);
@@ -180,16 +180,16 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
         * @param Tx_Extbase_Persistence_RowInterface $row
         * @return void
         */
-       protected function thawProperties(Tx_Extbase_DomainObject_DomainObjectInterface $object, Tx_Extbase_Persistence_RowInterface $row) {
+       protected function thawProperties(Tx_Extbase_DomainObject_DomainObjectInterface $object, array $row) {
                $className = get_class($object);
                $dataMap = $this->getDataMap($className);
                $properties = $object->_getProperties();
-               $localizedUid = $row->getValue('_LOCALIZED_UID');
+               $localizedUid = $row['_LOCALIZED_UID'];
                if ($localizedUid !== NULL) {
                        $object->_setProperty('uid', $localizedUid);
-                       $object->_setProperty('_localizationParentUid', $row->getValue('uid'));
+                       $object->_setProperty('_localizationParentUid', $row['uid']);
                } else {
-                       $object->_setProperty('uid', $row->getValue('uid'));
+                       $object->_setProperty('uid', $row['uid']);
                }
                unset($properties['uid']);
                foreach ($properties as $propertyName => $propertyValue) {
@@ -211,15 +211,15 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                                case Tx_Extbase_Persistence_PropertyType::LONG;
                                case Tx_Extbase_Persistence_PropertyType::DOUBLE;
                                case Tx_Extbase_Persistence_PropertyType::BOOLEAN;
-                               if ($row->hasValue($columnName)) {
-                                       $rawPropertyValue = $row->getValue($columnName);
+                               if (isset($row[$columnName])) {
+                                       $rawPropertyValue = $row[$columnName];
                                        $propertyValue = $dataMap->convertFieldValueToPropertyValue($propertyType, $rawPropertyValue);
                                }
                                break;
                                case (Tx_Extbase_Persistence_PropertyType::REFERENCE):
-                                       $propertyValue = $row->getValue($columnName);
+                                       $propertyValue = $row[$columnName];
                                        if (!is_null($propertyValue)) {
-                                               $fieldValue = $row->getValue($columnName);
+                                               $fieldValue = $row[$columnName];
                                                $result = $this->fetchRelated($object, $propertyName, $fieldValue);
                                                $propertyValue = $this->mapResultToPropertyValue($object, $propertyName, $result);
                                        }
@@ -308,7 +308,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                        if (isset($parentKeyFieldName)) {
                                $query->matching($query->equals($parentKeyFieldName, $parentObject->getUid()));
                        } else {
-                               $query->matching($query->equals('uid', t3lib_div::intExplode(',', $fieldValue)));                                       
+                               $query->matching($query->in('uid', t3lib_div::intExplode(',', $fieldValue)));                                   
                        }
                } elseif ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
                        $query = $queryFactory->create($this->getElementType($parentObject, $propertyName));
@@ -324,7 +324,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                        $source = $this->qomFactory->join(
                                $left,
                                $right,
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER,
+                               Tx_Extbase_Persistence_QueryInterface::JCR_JOIN_TYPE_INNER,
                                $joinCondition
                                );
 
index 40e7208..699157d 100644 (file)
@@ -86,7 +86,7 @@ class Tx_Extbase_Persistence_QOM_Comparison implements Tx_Extbase_Persistence_QO
        protected $operator;
 
        /**
-        * @var Tx_Extbase_Persistence_QOM_StaticOperandInterface
+        * @var mixed
         */
        protected $operand2;
 
@@ -94,26 +94,16 @@ class Tx_Extbase_Persistence_QOM_Comparison implements Tx_Extbase_Persistence_QO
         * Constructs this Comparison instance
         *
         * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1
-        * @param unknown_type $operator
-        * @param Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2
+        * @param int $operator one of Tx_Extbase_Persistence_QueryInterface.OPERATOR_*
+        * @param mixed $operand2
         */
-       public function __construct(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2) {
+       public function __construct(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, $operand2) {
                $this->operand1 = $operand1;
                $this->operator = $operator;
                $this->operand2 = $operand2;
        }
 
        /**
-        * Fills an array with the names of all bound variables in the operand
-        *
-        * @param array &$boundVariables
-        * @return void
-        */
-       public function collectBoundVariableNames(&$boundVariables) {
-               $this->operand2->collectBoundVariablenames($boundVariables);
-       }
-
-       /**
         *
         * Gets the first operand.
         *
@@ -135,7 +125,7 @@ class Tx_Extbase_Persistence_QOM_Comparison implements Tx_Extbase_Persistence_QO
        /**
         * Gets the second operand.
         *
-        * @return Tx_Extbase_Persistence_QOM_StaticOperandInterface the operand; non-null
+        * @return mixed the operand; non-null
         */
        public function getOperand2() {
                return $this->operand2;
diff --git a/typo3/sysext/extbase/Classes/Persistence/QOM/Constraint.php b/typo3/sysext/extbase/Classes/Persistence/QOM/Constraint.php
new file mode 100644 (file)
index 0000000..97538ec
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+*  All rights reserved
+*
+*  This class is a backport of the corresponding class of FLOW3.
+*  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!
+***************************************************************/
+
+/**
+ * Base class for constraints in the QOM.
+ *
+ * @version $Id: Constraint.php 3616 2010-01-13 16:30:32Z k-fish $
+ * @api
+ * @scope prototype
+ */
+class Constraint {}
+
+?>
\ No newline at end of file
index c5abc02..d814b63 100644 (file)
@@ -131,46 +131,6 @@ class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements Tx_Extbase_P
        }
 
        /**
-        * Tests whether a first selector's node is the same as a node identified by relative path from a second selector's node.
-        *
-        * @param string $selector1Name the name of the first selector; non-null
-        * @param string $selector2Name the name of the second selector; non-null
-        * @param string $selector2Path the path relative to the second selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_SameNodeJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function sameNodeJoinCondition($selector1Name, $selector2Name, $selector2Path = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058190);
-       }
-
-       /**
-        * Tests whether a first selector's node is a child of a second selector's node.
-        *
-        * @param string $childSelectorName the name of the child selector; non-null
-        * @param string $parentSelectorName the name of the parent selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_ChildNodeJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function childNodeJoinCondition($childSelectorName, $parentSelectorName) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058190);
-       }
-
-       /**
-        * Tests whether a first selector's node is a descendant of a second selector's node.
-        *
-        * @param string $descendantSelectorName the name of the descendant selector; non-null
-        * @param string $ancestorSelectorName the name of the ancestor selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_DescendantNodeJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function descendantNodeJoinCondition($descendantSelectorName, $ancestorSelectorName) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058192);
-       }
-
-       /**
         * Performs a logical conjunction of two other constraints.
         *
         * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null
@@ -207,18 +167,7 @@ class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements Tx_Extbase_P
        public function not(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint) {
                return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_LogicalNot', $constraint);
        }
-
-       /**
-        * Filters related node-tuples based on an object property.
-        *
-        * @param Tx_Extbase_DomainObject_AbstractEntity $object The object
-        * @param string $propertyName The name of the property of the related object
-        * @return Tx_Extbase_Persistence_QOM_RelatedInterface the constraint; non-null
-        */
-       public function related(Tx_Extbase_DomainObject_AbstractEntity $object, $propertyName) {
-               return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_Related', $object, $propertyName);
-       }
-
+       
        /**
         * Filters node-tuples based on the outcome of a binary operation.
         *
@@ -229,76 +178,10 @@ class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements Tx_Extbase_P
         * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
         * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
         */
-       public function comparison(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2) {
+       public function comparison(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, $operand2) {
                return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_Comparison', $operand1, $operator, $operand2);
        }
-
-       /**
-        * Tests the existence of a property in the specified or default selector.
-        *
-        * @param string $propertyName the property name; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_PropertyExistenceInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function propertyExistence($propertyName, $selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058196);
-       }
-
-       /**
-        * Performs a full-text search against the specified or default selector.
-        *
-        * @param string $propertyName the property name, or null to search all full-text indexed properties of the node (or node subgraph, in some implementations);
-        * @param string $fullTextSearchExpression the full-text search expression; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_FullTextSearchInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function fullTextSearch($propertyName, $fullTextSearchExpression, $selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058197);
-       }
-
-       /**
-        * Tests whether a node in the specified or default selector is reachable by a specified absolute path.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @param string $path an absolute path; non-null
-        * @return Tx_Extbase_Persistence_QOM_SameNodeInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function sameNode($path, $selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058198);
-       }
-
-       /**
-        * Tests whether a node in the specified or default selector is a child of a node reachable by a specified absolute path.
-        *
-        * @param string $path an absolute path; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_ChildNodeInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function childNode($path, $selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058199);
-       }
-
-       /**
-        * Tests whether a node in the specified or default selector is a descendant of a node reachable by a specified absolute path.
-        *
-        * @param string $path an absolute path; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_DescendantNodeInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function descendantNode($path, $selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058200);
-       }
-
+       
        /**
         * Evaluates to the value (or values, if multi-valued) of a property in the specified or default selector.
         *
@@ -311,55 +194,7 @@ class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements Tx_Extbase_P
        public function propertyValue($propertyName, $selectorName = '') {
                return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_PropertyValue', $propertyName, $selectorName);
        }
-
-       /**
-        * Evaluates to the length (or lengths, if multi-valued) of a property.
-        *
-        * @param Tx_Extbase_Persistence_QOM_PropertyValueInterface $propertyValue the property value for which to compute the length; non-null
-        * @return Tx_Extbase_Persistence_QOM_LengthInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function length(Tx_Extbase_Persistence_QOM_PropertyValueInterface $propertyValue) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058202);
-       }
-
-       /**
-        * Evaluates to a NAME value equal to the prefix-qualified name of a node in the specified or default selector.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_NodeNameInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function nodeName($selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058203);
-       }
-
-       /**
-        * Evaluates to a NAME value equal to the local (unprefixed) name of a node in the specified or default selector.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_NodeLocalNameInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function nodeLocalName($selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058204);
-       }
-
-       /**
-        * Evaluates to a DOUBLE value equal to the full-text search score of a node in the specified or default selector.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_FullTextSearchScoreInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function fullTextSearchScore($selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058205);
-       }
-
+       
        /**
         * Evaluates to the lower-case string value (or values, if multi-valued) of an operand.
         *
@@ -383,33 +218,7 @@ class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements Tx_Extbase_P
        public function upperCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) {
                return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_UpperCase', $operand);
        }
-
-       /**
-        * Evaluates to the value of a bind variable.
-        *
-        * @param string $bindVariableName the bind variable name; non-null
-        * @return Tx_Extbase_Persistence_QOM_BindVariableValueInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function bindVariable($bindVariableName) {
-               return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_BindVariableValue', $bindVariableName);
-       }
-
-       /**
-        * Evaluates to a literal value.
-        *
-        * The query is invalid if no value is bound to $literalValue.
-        *
-        * @param \F3\PHPCR\ValueInterface $literalValue the value
-        * @return \F3\PHPCR\ValueInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function literal(Tx_Extbase_Persistence_ValueInterface $literalValue) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058209);
-       }
-
+       
        /**
         * Orders by the value of the specified operand, in ascending order.
         *
@@ -437,36 +246,18 @@ class Tx_Extbase_Persistence_QOM_QueryObjectModelFactory implements Tx_Extbase_P
        public function descending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand) {
                return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_Ordering', $operand, Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_ORDER_DESCENDING);
        }
-
+       
        /**
-        * Identifies a property in the specified or default selector to include in
-        * the tabular view of query results.
-        * The column name is the property name if not given.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $propertyName is specified but it is not a syntactically valid JCR name, or
-        * $propertyName is specified but does not evaluate to a scalar value, or
-        * $propertyName is specified but $columnName is omitted, or
-        * $propertyName is omitted but $columnName is specified, or
-        * the columns in the tabular view are not uniquely named, whether those
-        * column names are specified by $columnName (if $propertyName is specified)
-        * or generated as described above (if $propertyName is omitted).
-        *
-        * If $propertyName is specified but, for a node-tuple, the selector node
-        * does not have a property named $propertyName, the query is valid and the
-        * column has null value.
+        * Evaluates to the value of a bind variable.
         *
-        * @param string $propertyName the property name, or null to include a column for each single-value non-residual property of the selector's node type
-        * @param string $columnName the column name; must be null if propertyName is null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_ColumnInterface the column; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query has no default selector or is otherwise invalid
+        * @param string $bindVariableName the bind variable name; non-null
+        * @return Tx_Extbase_Persistence_QOM_BindVariableValueInterface the operand; non-null
+        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
         * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
         */
-       public function column($propertyName, $columnName = NULL, $selectorName = NULL) {
-               throw new Tx_Extbase_Persistence_Exception('Method not yet implemented, sorry!', 1217058211);
+       public function bindVariable($bindVariableName) {
+               return t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_BindVariableValue', $bindVariableName);
        }
-
+       
 }
 ?>
index 15c5d4d..af18fa1 100644 (file)
  */
 interface Tx_Extbase_Persistence_QOM_QueryObjectModelFactoryInterface extends Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface {
 
-       /**
-        * Creates a query with one or more selectors.
-        * If source is a selector, that selector is the default selector of the
-        * query. Otherwise the query does not have a default selector.
-        *
-        * If the query is invalid, this method throws an InvalidQueryException.
-        * See the individual QOM factory methods for the validity criteria of each
-        * query element.
-        *
-        * @param mixed $source the Selector or the node-tuple Source; non-null
-        * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint the constraint, or null if none
-        * @param array $orderings zero or more orderings; null is equivalent to a zero-length array
-        * @param array $columns the columns; null is equivalent to a zero-length array
-        * @return Tx_Extbase_Persistence_QOM_QueryObjectModelInterface the query; non-null
-        */
-       public function createQuery(Tx_Extbase_Persistence_QOM_SourceInterface $selectorOrSource, $constraint, array $orderings, array $columns);
-
-       /**
-        * Selects a subset of the nodes in the repository based on node type.
-        *
-        * The query is invalid if $nodeTypeName or $selectorName is not a
-        * syntactically valid JCR name.
-        *
-        * The query is invalid if $selectorName is identical to the name of another
-        * selector in the query.
-        *
-        * If $nodeTypeName is a valid JCR name but not the name of a node type
-        * available in the repository, the query is valid but the selector selects
-        * no nodes.
-        *
-        * @param string $nodeTypeName the name of the required node type; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_SelectorInterface the selector; non-null
-        */
-       public function selector($nodeTypeName, $selectorName = NULL);
-
-       /**
-        * Performs a join between two node-tuple sources.
-        *
-        * The query is invalid if $left is the same source as $right.
-        *
-        * @param Tx_Extbase_Persistence_QOM_SourceInterface $left the left node-tuple source; non-null
-        * @param Tx_Extbase_Persistence_QOM_SourceInterface $right the right node-tuple source; non-null
-        * @param string $joinType one of QueryObjectModelConstants.JCR_JOIN_TYPE_*
-        * @param Tx_Extbase_Persistence_QOM_JoinConditionInterface $join Condition the join condition; non-null
-        * @return Tx_Extbase_Persistence_QOM_JoinInterface the join; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function join(Tx_Extbase_Persistence_QOM_SourceInterface $left, Tx_Extbase_Persistence_QOM_SourceInterface $right, $joinType, Tx_Extbase_Persistence_QOM_JoinConditionInterface $joinCondition);
-
-       /**
-        * Tests whether the value of a property in a first selector is equal to the
-        * value of a property in a second selector.
-        *
-        * The query is invalid if:
-        * * $selector1 is not the name of a selector in the query, or
-        * * $selector2 is not the name of a selector in the query, or
-        * * $selector1 is the same as $selector2, or
-        * * $property1 is not a syntactically valid JCR name, or
-        * * $property2 is not a syntactically valid JCR name, or
-        * * the value of $property1 is not the same property type as the value of
-        *   $property2, or
-        * * $property1 is a multi-valued property, or
-        * * $property2 is a multi-valued property, or
-        * * $property1 is a BINARY property, or
-        * * $property2 is a BINARY property.
-        *
-        * @param string $selector1Name the name of the first selector; non-null
-        * @param string $property1Name the property name in the first selector; non-null
-        * @param string $selector2Name the name of the second selector; non-null
-        * @param string $property2Name the property name in the second selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_EquiJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function equiJoinCondition($selector1Name, $property1Name, $selector2Name, $property2Name);
-
-       /**
-        * Tests whether a first selector's node is the same as a node identified by
-        * relative path from a second selector's node.
-        *
-        * The query is invalid if:
-        * * $selector1 is not the name of a selector in the query, or
-        * * $selector2 is not the name of a selector in the query, or
-        * * $selector1 is the same as $selector2, or
-        * * $selector2Path is not a syntactically valid relative path.  Note, however,
-        *   that if the path is syntactically valid but does not identify a node
-        *   visible to the current session, the query is valid but the constraint
-        *   is not satisfied.
-        *
-        * @param string $selector1Name the name of the first selector; non-null
-        * @param string $selector2Name the name of the second selector; non-null
-        * @param string $selector2Path the path relative to the second selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_SameNodeJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function sameNodeJoinCondition($selector1Name, $selector2Name, $selector2Path = NULL);
-
-       /**
-        * Tests whether a first selector's node is a child of a second selector's node.
-        *
-        * The query is invalid if:
-        * $childSelector is not the name of a selector in the query, or
-        * $parentSelector is not the name of a selector in the query, or
-        * $childSelector is the same as $parentSelector.
-        *
-        * @param string $childSelectorName the name of the child selector; non-null
-        * @param string $parentSelectorName the name of the parent selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_ChildNodeJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function childNodeJoinCondition($childSelectorName, $parentSelectorName);
-
-       /**
-        * Tests whether a first selector's node is a descendant of a second selector's node.
-        *
-        * The query is invalid if:
-        * $descendantSelector is not the name of a selector in the query, or
-        * $ancestorSelector is not the name of a selector in the query, or
-        * $descendantSelector is the same as $ancestorSelector.
-        *
-        * @param string $descendantSelectorName the name of the descendant selector; non-null
-        * @param string $ancestorSelectorName the name of the ancestor selector; non-null
-        * @return Tx_Extbase_Persistence_QOM_DescendantNodeJoinConditionInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function descendantNodeJoinCondition($descendantSelectorName, $ancestorSelectorName);
-
-       /**
-        * Performs a logical conjunction of two other constraints.
-        *
-        * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null
-        * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2 the second constraint; non-null
-        * @return Tx_Extbase_Persistence_QOM_AndInterface the And constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function _and(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1, Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2);
-
-       /**
-        * Performs a logical disjunction of two other constraints.
-        *
-        * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1 the first constraint; non-null
-        * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2 the second constraint; non-null
-        * @return Tx_Extbase_Persistence_QOM_OrInterface the Or constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function _or(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint1, Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint2);
-
-       /**
-        * Performs a logical negation of another constraint.
-        *
-        * @param Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint the constraint to be negated; non-null
-        * @return Tx_Extbase_Persistence_QOM_NotInterface the Not constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function not(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint);
-
-       /**
-        * Filters node-tuples based on the outcome of a binary operation.
-        *
-        * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1 the first operand; non-null
-        * @param string $operator the operator; one of QueryObjectModelConstants.JCR_OPERATOR_*
-        * @param Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2 the second operand; non-null
-        * @return Tx_Extbase_Persistence_QOM_ComparisonInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function comparison(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand1, $operator, Tx_Extbase_Persistence_QOM_StaticOperandInterface $operand2);
-
-       /**
-        * Tests the existence of a property in the specified or default selector.
-        *
-        * The query is invalid if:
-        *
-        * $propertyName is not a syntactically valid JCR name, or
-        * $selectorName is not the name of a selector in the query.
-        *
-        * @param string $propertyName the property name; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_PropertyExistenceInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function propertyExistence($propertyName, $selectorName = NULL);
-
-       /**
-        * Performs a full-text search against the specified or default selector.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $propertyName is specified but is not a syntactically valid JCR name, or
-        * $fullTextSearchExpression does not conform to the full text search grammar.
-        *
-        * If $propertyName is specified but, for a node-tuple, the selector node
-        * does not have a property named $propertyName, the query is valid but the
-        * constraint is not satisfied.
-        *
-        * @param string $propertyName the property name, or null to search all full-text indexed properties of the node (or node subgraph, in some implementations);
-        * @param string $fullTextSearchExpression the full-text search expression; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_FullTextSearchInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function fullTextSearch($propertyName, $fullTextSearchExpression, $selectorName = NULL);
-
-       /**
-        * Tests whether a node in the specified or default selector is reachable by
-        * a specified absolute path.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $path is not a syntactically valid absolute path.  Note,
-        * however, that if the path is syntactically valid but does not identify a
-        * node in the repository (or the node is not visible to this session,
-        * because of access control constraints), the query is valid but the
-        * constraint is not satisfied.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @param string $path an absolute path; non-null
-        * @return Tx_Extbase_Persistence_QOM_SameNodeInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function sameNode($path, $selectorName = NULL);
-
-       /**
-        * Tests whether a node in the specified or default selector is a child of a
-        * node reachable by a specified absolute path.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $path is not a syntactically valid absolute path.  Note,
-        * however, that if the path is syntactically valid but does not identify a
-        * node in the repository (or the node is not visible to this session,
-        * because of access control constraints), the query is valid but the
-        * constraint is not satisfied.
-        *
-        * @param string $path an absolute path; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_ChildNodeInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function childNode($path, $selectorName = NULL);
-
-       /**
-        * Tests whether a node in the specified or default selector is a descendant
-        * of a node reachable by a specified absolute path.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $path is not a syntactically valid absolute path.  Note,
-        * however, that if the path is syntactically valid but does not identify a
-        * node in the repository (or the node is not visible to this session,
-        * because of access control constraints), the query is valid but the
-        * constraint is not satisfied.
-        *
-        * @param string $path an absolute path; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_DescendantNodeInterface the constraint; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function descendantNode($path, $selectorName = NULL);
-
-       /**
-        * Evaluates to the value (or values, if multi-valued) of a property in the
-        * specified or default selector.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $propertyName is not a syntactically valid JCR name.
-        *
-        * @param string $propertyName the property name; non-null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_PropertyValueInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function propertyValue($propertyName, $selectorName = NULL);
-
-       /**
-        * Evaluates to the length (or lengths, if multi-valued) of a property.
-        *
-        * @param Tx_Extbase_Persistence_QOM_PropertyValueInterface $propertyValue the property value for which to compute the length; non-null
-        * @return Tx_Extbase_Persistence_QOM_LengthInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function length(Tx_Extbase_Persistence_QOM_PropertyValueInterface $propertyValue);
-
-       /**
-        * Evaluates to a NAME value equal to the prefix-qualified name of a node in
-        * the specified or default selector.
-        *
-        * The query is invalid if $selectorName is not the name of a selector in
-        * the query.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_NodeNameInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function nodeName($selectorName = NULL);
-
-       /**
-        * Evaluates to a NAME value equal to the local (unprefixed) name of a node in the specified or default selector.
-        *
-        * The query is invalid if $selectorName is not the name of a selector in
-        * the query.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_NodeLocalNameInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function nodeLocalName($selectorName = NULL);
-
-       /**
-        * Evaluates to a DOUBLE value equal to the full-text search score of a node in the specified or default selector.
-        *
-        * The query is invalid if $selectorName is not the name of a selector in
-        * the query.
-        *
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_FullTextSearchScoreInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function fullTextSearchScore($selectorName = NULL);
-
-       /**
-        * Evaluates to the lower-case string value (or values, if multi-valued) of an operand.
-        *
-        * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand whose value is converted to a lower-case string; non-null
-        * @return Tx_Extbase_Persistence_QOM_LowerCaseInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function lowerCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand);
-
-       /**
-        * Evaluates to the upper-case string value (or values, if multi-valued) of an operand.
-        *
-        * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand whose value is converted to a upper-case string; non-null
-        * @return Tx_Extbase_Persistence_QOM_UpperCaseInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function upperCase(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand);
-
-       /**
-        * Evaluates to the value of a bind variable.
-        *
-        * The query is invalid if $bindVariableName is not a valid JCR prefix.
-        *
-        * @param string $bindVariableName the bind variable name; non-null
-        * @return Tx_Extbase_Persistence_QOM_BindVariableValueInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function bindVariable($bindVariableName);
-
-       /**
-        * Evaluates to a literal value.
-        *
-        * The query is invalid if no value is bound to $literalValue.
-        *
-        * @param \F3\PHPCR\ValueInterface $literalValue the value
-        * @return \F3\PHPCR\ValueInterface the operand; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if a particular validity test is possible on this method, the implemention chooses to perform that test (and not leave it until later) on createQuery, and the parameters given fail that test
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function literal(Tx_Extbase_Persistence_ValueInterface $literalValue);
-
-       /**
-        * Orders by the value of the specified operand, in ascending order.
-        *
-        * The query is invalid if $operand does not evaluate to a scalar value.
-        *
-        * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand by which to order; non-null
-        * @return Tx_Extbase_Persistence_QOM_OrderingInterface the ordering
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function ascending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand);
-
-       /**
-        * Orders by the value of the specified operand, in descending order.
-        *
-        * The query is invalid if $operand does not evaluate to a scalar value.
-        *
-        * @param Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand the operand by which to order; non-null
-        * @return Tx_Extbase_Persistence_QOM_OrderingInterface the ordering
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query is invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function descending(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand);
-
-       /**
-        * Identifies a property in the specified or default selector to include in
-        * the tabular view of query results.
-        * The column name is the property name if not given.
-        *
-        * The query is invalid if:
-        * $selectorName is not the name of a selector in the query, or
-        * $propertyName is specified but it is not a syntactically valid JCR name, or
-        * $propertyName is specified but does not evaluate to a scalar value, or
-        * $propertyName is specified but $columnName is omitted, or
-        * $propertyName is omitted but $columnName is specified, or
-        * the columns in the tabular view are not uniquely named, whether those
-        * column names are specified by $columnName (if $propertyName is specified)
-        * or generated as described above (if $propertyName is omitted).
-        *
-        * If $propertyName is specified but, for a node-tuple, the selector node
-        * does not have a property named $propertyName, the query is valid and the
-        * column has null value.
-        *
-        * @param string $propertyName the property name, or null to include a column for each single-value non-residual property of the selector's node type
-        * @param string $columnName the column name; must be null if propertyName is null
-        * @param string $selectorName the selector name; non-null
-        * @return Tx_Extbase_Persistence_QOM_ColumnInterface the column; non-null
-        * @throws \F3\PHPCR\Query\InvalidQueryException if the query has no default selector or is otherwise invalid
-        * @throws Tx_Extbase_Persistence_Exception_RepositoryException if the operation otherwise fails
-        */
-       public function column($propertyName, $columnName = NULL, $selectorName = NULL);
 
 }
 
index 5b177be..fea2617 100644 (file)
@@ -47,19 +47,19 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
        protected $dataMapper;
 
        /**
-        * @var Tx_Extbase_Persistence_QOM_QueryObjectModelFactoryInterface
+        * @var Tx_Extbase_Persistence_Manager
         */
-       protected $QOMFactory;
+       protected $persistenceManager;
 
        /**
-        * @var Tx_Extbase_Persistence_ValueFactoryInterface
+        * @var Tx_Extbase_Persistence_QOM_QueryObjectModelFactoryInterface
         */
-       protected $valueFactory;
+       protected $qomFactory;
 
        /**
-        * @var Tx_Extbase_Persistence_ManagerInterface
+        * @var Tx_Extbase_Persistence_ValueFactoryInterface
         */
-       protected $persistenceManager;
+       protected $valueFactory;
 
        /**
         * @var Tx_Extbase_Persistence_QOM_SourceInterface
@@ -121,7 +121,7 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         */
        public function injectPersistenceManager(Tx_Extbase_Persistence_ManagerInterface $persistenceManager) {
                $this->persistenceManager = $persistenceManager;
-               $this->QOMFactory = $this->persistenceManager->getBackend()->getQOMFactory();
+               $this->qomFactory = $this->persistenceManager->getBackend()->getQomFactory();
                $this->valueFactory = $this->persistenceManager->getBackend()->getValueFactory();
        }
 
@@ -148,11 +148,11 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
 
        /**
         * Returns the Query Settings.
-        *
+        * 
         * @return Tx_Extbase_Persistence_QuerySettingsInterface $querySettings The Query Settings
-        * @api
         */
        public function getQuerySettings() {
+               if (!($this->querySettings instanceof Tx_Extbase_Persistence_QuerySettingsInterface)) throw new Tx_Extbase_Persistence_Exception('Tried to get the query settings without seting them before.', 1248689115);
                return $this->querySettings;
        }
 
@@ -173,6 +173,31 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
        public function setSource(Tx_Extbase_Persistence_QOM_SourceInterface $source) {
                $this->source = $source;
        }
+       
+       /**
+        * Returns the selectorn name or an empty string, if the source is not a selector
+        * // TODO This has to be checked at another place
+        * @return string The selector name
+        */
+       protected function getSelectorName() {
+               if ($this->getSource() instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
+                       return $this->source->getSelectorName();
+               } else {
+                       return '';
+               }
+       }
+
+       /**
+        * Gets the node-tuple source for this query.
+        *
+        * @return Tx_Extbase_Persistence_QOM_SourceInterface the node-tuple source; non-null
+       */
+       public function getSource() {
+               if ($this->source === NULL) {
+                       $this->source = $this->qomFactory->selector($this->className, $this->dataMapper->convertClassNameToTableName($this->className));
+               }
+               return $this->source;
+       }
 
        /**
         * Executes the query against the database and returns the result
@@ -181,22 +206,22 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @api
         */
        public function execute() {
-               $result = $this->getPreparedQueryObjectModel()->execute();
+               $rows = $this->persistenceManager->getObjectDataByQuery($this);
                if ($this->getQuerySettings()->getReturnRawQueryResult() === TRUE) {
-                       return $result;
+                       return $rows;
                } else {
-                       return $this->dataMapper->map($this->className, $result->getRows());
+                       return $this->dataMapper->map($this->className, $rows);
                }
        }
        
        /**
-        * Executes the query against the database and returns the number of matching objects
+        * Executes the number of matching objects for the query
         *
         * @return integer The number of matching objects
         * @api
         */
        public function count() {
-               return $this->getPreparedQueryObjectModel()->count();
+               return $this->persistenceManager->getObjectCountByQuery($this);
        }
        
        /**
@@ -206,17 +231,17 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         */
        protected function getPreparedQueryObjectModel() {
                if ($this->source === NULL) {
-                       $this->source = $this->QOMFactory->selector($this->className, $this->dataMapper->convertClassNameToTableName($this->className));
+                       $this->source = $this->qomFactory->selector($this->className, $this->dataMapper->convertClassNameToTableName($this->className));
                }
                if ($this->constraint instanceof Tx_Extbase_Persistence_QOM_StatementInterface) {
-                       $query = $this->QOMFactory->createQuery(
+                       $query = $this->qomFactory->createQuery(
                                $this->source,
                                $this->constraint,
                                array(),
                                array()
                        );
                } else {
-                       $query = $this->QOMFactory->createQuery(
+                       $query = $this->qomFactory->createQuery(
                                $this->source,
                                $this->constraint,
                                $this->orderings,
@@ -263,9 +288,9 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
                $parsedOrderings = array();
                foreach ($orderings as $propertyName => $order) {
                        if ($order === Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING) {
-                               $parsedOrderings[] = $this->QOMFactory->descending($this->QOMFactory->propertyValue($propertyName));
+                               $parsedOrderings[] = $this->qomFactory->descending($this->qomFactory->propertyValue($propertyName));
                        } elseif ($order === Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING) {
-                               $parsedOrderings[] = $this->QOMFactory->ascending($this->QOMFactory->propertyValue($propertyName));
+                               $parsedOrderings[] = $this->qomFactory->ascending($this->qomFactory->propertyValue($propertyName));
                        } else {
                                throw new Tx_Extbase_Persistence_Exception_UnsupportedOrder('The order you specified for your query is not supported.', 1253785630);
                        }
@@ -273,6 +298,20 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
                $this->orderings = $parsedOrderings;
                return $this;
        }
+       
+       /**
+        * Returns the property names to order the result by. Like this:
+        * array(
+        *  'foo' => \F3\FLOW3\Persistence\QueryInterface::ORDER_ASCENDING,
+        *  'bar' => \F3\FLOW3\Persistence\QueryInterface::ORDER_DESCENDING
+        * )
+        *
+        * @return array
+        * @api
+        */
+       public function getOrderings() {
+               return $this->orderings;
+       }
 
        /**
         * Sets the maximum size of the result set to limit. Returns $this to allow
@@ -289,6 +328,16 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
        }
 
        /**
+        * Returns the maximum size of the result set to limit.
+        *
+        * @param integer
+        * @api
+        */
+       public function getLimit() {
+               return $this->limit;
+       }
+
+       /**
         * Sets the start offset of the result set to offset. Returns $this to
         * allow for chaining (fluid interface)
         *
@@ -303,6 +352,16 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
        }
 
        /**
+        * Returns the start offset of the result set.
+        *
+        * @return integer
+        * @api
+        */
+       public function getOffset() {
+               return $this->offset;
+       }
+       
+       /**
         * The constraint used to limit the result set. Returns $this to allow
         * for chaining (fluid interface)
         *
@@ -325,15 +384,20 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_StatementInterface
         */
        public function statement($statement, array $parameters = array(), $language = Tx_Extbase_Persistence_QOM_QueryObjectModelInterface::TYPO3_SQL_MYSQL) {
-               $boundVariables = array();
-               foreach ($parameters as $parameter) {
-                       $uniqueVariableName = uniqid();
-                       $this->operands[$uniqueVariableName] = $parameter;
-                       $boundVariables[$uniqueVariableName] = $this->QOMFactory->bindVariable($uniqueVariableName);
-               }
-               $this->constraint = $this->QOMFactory->statement($statement, $boundVariables, $language);
+               $this->constraint = $this->qomFactory->statement($statement, $parameters, $language);
                return $this;
        }
+       
+       /**
+        * Gets the constraint for this query.
+        *
+        * @return Tx_Extbase_Persistence_QOM_Constraint the constraint, or null if none
+        * @author Karsten Dambekalns <karsten@typo3.org>
+        * @api
+       */
+       public function getConstraint() {
+               return $this->constraint;
+       }
 
        /**
         * Performs a logical conjunction of the two given constraints.
@@ -344,7 +408,7 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @api
         */
        public function logicalAnd($constraint1, $constraint2) {
-               return $this->QOMFactory->_and(
+               return $this->qomFactory->_and(
                        $constraint1,
                        $constraint2
                        );
@@ -359,7 +423,7 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @api
         */
        public function logicalOr($constraint1, $constraint2) {
-               return $this->QOMFactory->_or(
+               return $this->qomFactory->_or(
                        $constraint1,
                        $constraint2
                        );
@@ -373,7 +437,7 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @api
         */
        public function logicalNot($constraint) {
-               return $this->QOMFactory->not($constraint);
+               return $this->qomFactory->not($constraint);
        }
 
        /**
@@ -383,13 +447,11 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         * @api
         */
-       public function withUid($uid) {
-               $uniqueVariableName = $this->getUniqueVariableName('uid');
-               $this->operands[$uniqueVariableName] = $uid;
-               return $this->QOMFactory->comparison(
-                       $this->QOMFactory->propertyValue('uid', $this->getSelectorName()),
-                       Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
-                       $this->QOMFactory->bindVariable($uniqueVariableName)
+       public function withUid($operand) {
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue('uid', $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
+                       $operand
                        );
        }
 
@@ -402,31 +464,20 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         */
        public function equals($propertyName, $operand, $caseSensitive = TRUE) {
-               $uniqueVariableName = uniqid($propertyName);
-               if (is_object($operand) && !($operand instanceof DateTime)) {
-                       $operand = $this->persistenceManager->getBackend()->getIdentifierByObject($operand);
-               }
-               if ($caseSensitive) {
-                       $comparison = $this->QOMFactory->comparison(
-                               $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
-                               $this->QOMFactory->bindVariable($uniqueVariableName)
-                               );
+               if (is_object($operand) || $caseSensitive) {
+                       $comparison = $this->qomFactory->comparison(
+                               $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
+                               $operand
+                       );
                } else {
-                       $comparison = $this->QOMFactory->comparison(
-                               $this->QOMFactory->lowerCase(
-                                       $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName())
+                       $comparison = $this->qomFactory->comparison(
+                               $this->qomFactory->lowerCase(
+                                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName())
                                ),
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
-                               $this->QOMFactory->bindVariable($uniqueVariableName)
-                               );
-               }
-
-               // TODO Implement case sensitivity for arrays (callback)
-               if ($caseSensitive || !is_string($operand)) {
-                       $this->operands[$uniqueVariableName] = $operand;
-               } else {
-                       $this->operands[$uniqueVariableName] = strtolower($operand);
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
+                               strtolower($operand)
+                       );
                }
 
                return $comparison;
@@ -440,14 +491,50 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         */
        public function like($propertyName, $operand) {
-               $uniqueVariableName = uniqid($propertyName);
-               $this->operands[$uniqueVariableName] = $operand;
-               return $this->QOMFactory->comparison(
-                       $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
-                       Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE,
-                       $this->QOMFactory->bindVariable($uniqueVariableName)
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_LIKE,
+                       $operand
                        );
        }
+       
+       /**
+        * 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 Tx_Extbase_Persistence_QOM_ComparisonInterface
+        * @api
+        */
+       public function contains($propertyName, $operand){
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_CONTAINS,
+                       $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 Tx_Extbase_Persistence_QOM_ComparisonInterface
+        * @api
+        */
+       public function in($propertyName, $operand) {
+               if (!is_array($operand) && (!$operand instanceof ArrayAccess) && (!$operand instanceof Traversable)) {
+                       throw new Tx_Extbase_Persistence_Exception_UnexpectedTypeException('The "in" operator must be given a mutlivalued operand (array, ArrayAccess, Traversable).', 1264678095);
+               }
+               
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_IN,
+                       $operand
+               );
+       }
 
        /**
         * Returns a less than criterion used for matching objects against a query
@@ -457,12 +544,10 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         */
        public function lessThan($propertyName, $operand) {
-               $uniqueVariableName = uniqid($propertyName);
-               $this->operands[$uniqueVariableName] = $operand;
-               return $this->QOMFactory->comparison(
-                       $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
-                       Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN,
-                       $this->QOMFactory->bindVariable($uniqueVariableName)
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_LESS_THAN,
+                       $operand
                        );
        }
 
@@ -474,12 +559,10 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         */
        public function lessThanOrEqual($propertyName, $operand) {
-               $uniqueVariableName = uniqid($propertyName);
-               $this->operands[$uniqueVariableName] = $operand;
-               return $this->QOMFactory->comparison(
-                       $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
-                       Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,
-                       $this->QOMFactory->bindVariable($uniqueVariableName)
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_LESS_THAN_OR_EQUAL_TO,
+                       $operand
                        );
        }
 
@@ -491,12 +574,10 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         */
        public function greaterThan($propertyName, $operand) {
-               $uniqueVariableName = uniqid($propertyName);
-               $this->operands[$uniqueVariableName] = $operand;
-               return $this->QOMFactory->comparison(
-                       $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
-                       Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN,
-                       $this->QOMFactory->bindVariable($uniqueVariableName)
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_GREATER_THAN,
+                       $operand
                        );
        }
 
@@ -508,41 +589,12 @@ class Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_QueryInterf
         * @return Tx_Extbase_Persistence_QOM_ComparisonInterface
         */
        public function greaterThanOrEqual($propertyName, $operand) {
-               $uniqueVariableName = uniqid($propertyName);
-               $this->operands[$uniqueVariableName] = $operand;
-               return $this->QOMFactory->comparison(
-                       $this->QOMFactory->propertyValue($propertyName, $this->getSelectorName()),
-                       Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO,
-                       $this->QOMFactory->bindVariable($uniqueVariableName)
+               return $this->qomFactory->comparison(
+                       $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
+                       Tx_Extbase_Persistence_QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO,
+                       $operand
                        );
        }
-
-       /**
-        * Returns a unique variable name for a given property name. This is necessary for storing
-        * the variable values in an associative array without overwriting existing variables.
-        *
-        * @param string $propertyName The name of the property
-        * @return string The postfixed property name
-        */
-       protected function getUniqueVariableName($propertyName) {
-               return uniqid($propertyName);
-       }
-
-       /**
-        * Returns the selectorn name or an empty string, if the source is not a selector
-        * // TODO This has to be checked at another place
-        * @return string The selector name
-        */
-       protected function getSelectorName() {
-               if ($this->source === NULL) {
-                       $this->source = $this->QOMFactory->selector($this->className, $this->dataMapper->convertClassNameToTableName($this->className));
-               }
-               if ($this->source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
-                       return $this->source->getSelectorName();
-               } else {
-                       return '';
-               }
-       }
-
+               
 }
 ?>
\ No newline at end of file
index b9e6100..67018e1 100644 (file)
 interface Tx_Extbase_Persistence_QueryInterface {
 
        /**
+        * 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;
+
+       /**
         * Constants representing the direction when ordering result sets.
         */
        const ORDER_ASCENDING = 'ASC';
        const ORDER_DESCENDING = 'DESC';
 
        /**
+        * 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';
+
+       /**
         * Executes the query against the backend and returns the result
         *
         * @return array<object> The query result as an array of objects
@@ -160,6 +229,28 @@ interface Tx_Extbase_Persistence_QueryInterface {
        public function like($propertyName, $operand);
 
        /**
+        * 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);
+
+       /**
         * Returns a less than criterion used for matching objects against a query
         *
         * @param string $propertyName The name of the property to compare against
index 9184f1f..b44512b 100644 (file)
@@ -65,20 +65,22 @@ interface Tx_Extbase_Persistence_Storage_BackendInterface {
        public function removeRow($tableName, array $identifier, $isRelation = FALSE);
 
        /**
-        * Returns an array with rows matching the query.
+        * Returns the number of items matching the query.
         *
-        * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
-        * @return array
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return integer
+        * @api
         */
-       public function getRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query);
+       public function getObjectCountByQuery(Tx_Extbase_Persistence_QueryInterface $query);
 
        /**
-        * Returns the number of tuples matching the query.
+        * Returns the object data matching the $query.
         *
-        * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
-        * @return int The number of matching tuples
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return array
+        * @api
         */
-       public function countRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query);
-
+       public function getObjectDataByQuery(Tx_Extbase_Persistence_QueryInterface $query);
+       
 }
 ?>
\ No newline at end of file
index 3993752..34798de 100644 (file)
@@ -203,32 +203,39 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                }
                return implode(' AND ', $suffixedFieldNames);
        }
-
+       
        /**
-        * Returns an array with tuples matching the query.
+        * Returns the object data matching the $query.
         *
-        * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
-        * @return array The matching tuples
+        * @param Tx_Extbase_Persistence_QueryInterface $query
+        * @return array
+        * @author Karsten Dambekalns <karsten@typo3.org>
         */
-       public function getRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query) {
+       public function getObjectDataByQuery(Tx_Extbase_Persistence_QueryInterface $query) {
+               $parameters = array();
+               // $this->knownRecords = array();
+
                $constraint = $query->getConstraint();
                if($constraint instanceof Tx_Extbase_Persistence_QOM_StatementInterface) {
                        if ($constraint->getLanguage() === Tx_Extbase_Persistence_QOM_QueryObjectModelInterface::TYPO3_SQL_MYSQL) {
-                               $statement = $constraint->getStatement();
+                               $sql = $constraint->getStatement();
                                $parameters = $query->getBoundVariableValues();
                        } else {
                                throw new Tx_Extbase_Persistence_Exception('Unsupported query language.', 1248701951);
                        }
                } else {
                        $parameters = array();
-                       $statement = $this->getStatement($query, $parameters);
+                       $statementParts = $this->parseQuery($query, $parameters);                       
+                       $sql = $this->buildQuery($statementParts, $parameters);
                }
-               $this->replacePlaceholders($statement, $parameters);
-               // debug($statement,-2);
-               $result = $this->databaseHandle->sql_query($statement);
+               $this->replacePlaceholders($sql, $parameters);
+               // debug($sql,-2);
+               $result = $this->databaseHandle->sql_query($sql);
                $this->checkSqlErrors();
                $rows = $this->getRowsFromResult($query->getSource(), $result);
                $rows = $this->doLanguageAndWorkspaceOverlay($query->getSource(), $rows);
+
+               // $objectData = $this->processObjectRecords($statementHandle);
                return $rows;
        }
 
@@ -238,39 +245,28 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
         * @return int The number of matching tuples
         */
-       public function countRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query) {
+       public function getObjectCountByQuery(Tx_Extbase_Persistence_QueryInterface $query) {
                $constraint = $query->getConstraint();
                if($constraint instanceof Tx_Extbase_Persistence_QOM_StatementInterface) throw new Tx_Extbase_Persistence_Storage_Exception_BadConstraint('Could not execute count on queries with a constraint of type Tx_Extbase_Persistence_QOM_StatementInterface', 1256661045);
                $parameters = array();
                $statementParts = $this->parseQuery($query, $parameters);
                $statementParts['fields'] = array('COUNT(*)');
-               $statement = $this->buildStatement($statementParts, $parameters);
+               $statement = $this->buildQuery($statementParts, $parameters);
                $this->replacePlaceholders($statement, $parameters);
+               // debug($sql,-2);
                $result = $this->databaseHandle->sql_query($statement);
                $this->checkSqlErrors();
                $rows = $this->getRowsFromResult($query->getSource(), $result);
                return current(current($rows));
        }
-       
-       /**
-        * Returns the statement, ready to be executed.
-        *
-        * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
-        * @return string The SQL statement
-        */
-       public function getStatement(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query, array &$parameters) {
-               $statementParts = $this->parseQuery($query, $parameters);
-               $statement = $this->buildStatement($statementParts);
-               return $statement;
-       }
-       
+               
        /**
         * Parses the query and returns the SQL statement parts.
         *
         * @param Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query
         * @return array The SQL statement parts
         */
-       public function parseQuery(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query, array &$parameters) {
+       public function parseQuery(Tx_Extbase_Persistence_Query $query, array &$parameters) {
                $sql = array();
                $sql['tables'] = array();
                $sql['fields'] = array();
@@ -282,7 +278,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                $source = $query->getSource();
                
                $this->parseSource($query, $source, $sql, $parameters);
-               $this->parseConstraint($query->getConstraint(), $source, $sql, $parameters, $query->getBoundVariableValues());
+               $this->parseConstraint($query->getConstraint(), $source, $sql, $parameters);
                $this->parseOrderings($query->getOrderings(), $source, $sql);
                $this->parseLimitAndOffset($query->getLimit(), $query->getOffset(), $sql);
 
@@ -295,7 +291,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param array $sql The SQL statement parts
         * @return string The SQL statement
         */
-       public function buildStatement(array $sql) {
+       public function buildQuery(array $sql) {
                $statement = 'SELECT ' . implode(',', $sql['fields']) . ' FROM ' . implode(' ', $sql['tables']);
                if (!empty($sql['where'])) {
                        $statement .= ' WHERE ' . implode('', $sql['where']);
@@ -368,7 +364,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param array &$parameters
         * @return void
         */
-       protected function parseSource(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters) {
+       protected function parseSource(Tx_Extbase_Persistence_Query $query, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql) {
                if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
                        $tableName = $source->getSelectorName();
                        $sql['fields'][] = $tableName . '.*';
@@ -398,7 +394,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param array &$sql The query parts
         * @return void
         */
-       protected function parseJoin(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query, Tx_Extbase_Persistence_QOM_JoinInterface $join, array &$sql) {
+       protected function parseJoin(Tx_Extbase_Persistence_QueryInterface $query, Tx_Extbase_Persistence_QOM_JoinInterface $join, array &$sql) {
                $leftSource = $join->getLeft();
                $leftTableName = $leftSource->getSelectorName();
                $rightSource = $join->getRight();
@@ -447,28 +443,28 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param array $boundVariableValues The bound variables in the query (key) and their values (value)
         * @return void
         */
-       protected function parseConstraint(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint = NULL, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters, array $boundVariableValues) {
+       protected function parseConstraint(Tx_Extbase_Persistence_QOM_ConstraintInterface $constraint = NULL, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters) {
                if ($constraint === NULL) return;
                if ($constraint instanceof Tx_Extbase_Persistence_QOM_AndInterface) {
                        $sql['where'][] = '(';
-                       $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters, $boundVariableValues);
-                       $sql['where'][] = ' AND ';
-                       $this->parseConstraint($constraint->getConstraint2(), $source, $sql, $parameters, $boundVariableValues);
-                       $sql['where'][] = ')';
-               } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_OrInterface) {
-                       $sql['where'][] = '(';
-                       $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters, $boundVariableValues);
-                       $sql['where'][] = ' OR ';
-                       $this->parseConstraint($constraint->getConstraint2(), $source, $sql, $parameters, $boundVariableValues);
+                       $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters);
+                       $sql['where'][] = ' AND ';                                                      
+                       $this->parseConstraint($constraint->getConstraint2(), $source, $sql, $parameters);
+                       $sql['where'][] = ')';                                                          
+               } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_OrInterface) {          
+                       $sql['where'][] = '(';                                                          
+                       $this->parseConstraint($constraint->getConstraint1(), $source, $sql, $parameters);
+                       $sql['where'][] = ' OR ';                                                       
+                       $this->parseConstraint($constraint->getConstraint2(), $source, $sql, $parameters);
                        $sql['where'][] = ')';
                } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_NotInterface) {
                        $sql['where'][] = 'NOT (';
-                       $this->parseConstraint($constraint->getConstraint(), $source, $sql, $parameters, $boundVariableValues);
+                       $this->parseConstraint($constraint->getConstraint(), $source, $sql, $parameters);
                        $sql['where'][] = ')';
                } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_ComparisonInterface) {
-                       $this->parseComparison($constraint, $source, $sql, $parameters, $boundVariableValues);
+                       $this->parseComparison($constraint, $source, $sql, $parameters);
                } elseif ($constraint instanceof Tx_Extbase_Persistence_QOM_RelatedInterface) {
-                       $this->parseRelated($constraint, $sql, $parameters, $boundVariableValues);
+                       $this->parseRelated($constraint, $sql, $parameters);
                }
        }
 
@@ -482,27 +478,73 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param array $boundVariableValues The bound variables in the query and their values
         * @return void
         */
-       protected function parseComparison(Tx_Extbase_Persistence_QOM_ComparisonInterface $comparison, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters, array $boundVariableValues) {
-               if (!($comparison->getOperand2() instanceof Tx_Extbase_Persistence_QOM_BindVariableValueInterface)) throw new Tx_Extbase_Persistence_Exception('Type of operand is not supported', 1247581135);
-
-               $value = $boundVariableValues[$comparison->getOperand2()->getBindVariableName()];
+       protected function parseComparison(Tx_Extbase_Persistence_QOM_ComparisonInterface $comparison, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters) {
+               $operand1 = $comparison->getOperand1();
                $operator = $comparison->getOperator();
-               if ($value === NULL) {
-                       if ($operator === Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO) {
+               $operand2 = $comparison->getOperand2();
+               if (($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO) && (is_array($operand2) || ($operand2 instanceof ArrayAccess) || ($operand2 instanceof Traversable))) {
+                       // FIXME this else branch enables equals() to behave like in(). This behavior is deprecated and will be removed in future. Use in() instead.
+                       $operator = Tx_Extbase_Persistence_QueryInterface::OPERATOR_IN;
+               }
+               
+               if ($operand2 === NULL) {
+                       if ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO) {
                                $operator = self::OPERATOR_EQUAL_TO_NULL;
-                       } elseif ($operator === Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_NOT_EQUAL_TO) {
+                       } elseif ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_NOT_EQUAL_TO) {
                                $operator = self::OPERATOR_NOT_EQUAL_TO_NULL;
                        }
-               } elseif (is_array($value)) {
-                       if ($operator === Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO) {
-                               $operator = self::OPERATOR_IN;
-                       } elseif ($operator === Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_NOT_EQUAL_TO) {
-                               $operator = self::OPERATOR_NOT_IN;
-                       }                       
                }
-               $parameters[] = $value;
 
-               $this->parseDynamicOperand($comparison->getOperand1(), $operator, $source, $sql, $parameters);
+               if ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_IN) {
+                       $this->parseDynamicOperand($operand1, $operator, $source, $sql, $parameters, NULL, $operand2);
+                       $items = array();
+                       foreach ($operand2 as $value) {
+                               $items[] = $this->getPlainValue($value);
+                       }
+                       $parameters[] = $items;
+               } elseif ($operator === Tx_Extbase_Persistence_QueryInterface::OPERATOR_CONTAINS) {
+                       $dataMap = $this->dataMapper->getDataMap($source->getNodeTypeName());
+                       $columnMap = $dataMap->getColumnMap($operand1->getPropertyName());
+                       $typeOfRelation = $columnMap->getTypeOfRelation();
+                       if ($typeOfRelation === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
+                               $relationTableName = $columnMap->getRelationTableName();
+                               $sql['where'][] = 'uid IN (SELECT uid_local FROM ' . $relationTableName . ' WHERE uid_foreign=' . $this->getPlainValue($operand2) . ')';
+                       } elseif ($typeOfRelation === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
+                               $parentKeyFieldName = $columnMap->getParentKeyFieldName();
+                               if (isset($parentKeyFieldName)) {
+                                       $columnName = $this->dataMapper->convertPropertyNameToColumnName($operand1->getPropertyName(), $source->getNodeTypeName());
+                                       $childTableName = $columnMap->getChildTableName();
+                                       $sql['where'][] = 'uid=(SELECT ' . $childTableName . '.' . $parentKeyFieldName . ' FROM ' . $childTableName . ' WHERE ' . $childTableName . '.uid=' . $this->getPlainValue($operand2) . ')';
+                               } else {
+                                       $tableName = $operand1->getSelectorName();
+                                       $statement = '(' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'%,' . $this->getPlainValue($operand2) . ',%\'';
+                                       $statement .= ' OR ' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'%,' . $this->getPlainValue($operand2) . '\'';
+                                       $statement .= ' OR ' . $tableName . '.' . $operand1->getPropertyName() . ' LIKE \'' . $this->getPlainValue($operand2) . ',%\')';
+                                       $sql['where'][] = $statement;
+                               }
+                       } else {
+                               throw new Tx_Extbase_Persistence_Exception_RepositoryException('Unsupported relation for contains().', 1267832524);
+                       }
+               } else {
+                       $this->parseDynamicOperand($operand1, $operator, $source, $sql, $parameters);
+                       $parameters[] = $this->getPlainValue($operand2);
+               }
+       }
+       
+       /**
+        * Returns a plain value, i.e. objects are flattened out if possible.
+        *
+        * @param mixed $input
+        * @return mixed
+        */
+       protected function getPlainValue($input) {
+               if ($input instanceof DateTime) {
+                       return $input->getTimestamp();
+               } elseif ($input instanceof Tx_Extbase_DomainObject_DomainObjectinterface) {
+                       return $input->getUid();
+               } else {
+                       return $input;
+               }
        }
 
        /**
@@ -516,7 +558,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
         * @param string $valueFunction an optional SQL function to apply to the operand value
         * @return void
         */
-       protected function parseDynamicOperand(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand, $operator, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters, $valueFunction = NULL) {
+       protected function parseDynamicOperand(Tx_Extbase_Persistence_QOM_DynamicOperandInterface $operand, $operator, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql, array &$parameters, $valueFunction = NULL, $operand2 = NULL) {
                if ($operand instanceof Tx_Extbase_Persistence_QOM_LowerCaseInterface) {
                        $this->parseDynamicOperand($operand->getOperand(), $operator, $source, $sql, $parameters, 'LOWER');
                } elseif ($operand instanceof Tx_Extbase_Persistence_QOM_UpperCaseInterface) {
@@ -531,7 +573,6 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                        }
                        $columnName = $this->dataMapper->convertPropertyNameToColumnName($operand->getPropertyName(), $className);
                        $operator = $this->resolveOperator($operator);
-
                        if ($valueFunction === NULL) {
                                $constraintSQL .= (!empty($tableName) ? $tableName . '.' : '') . $columnName .  ' ' . $operator . ' ?';
                        } else {
@@ -556,31 +597,28 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                        case self::OPERATOR_NOT_EQUAL_TO_NULL:
                                $operator = 'IS NOT';
                                break;
-                       case self::OPERATOR_IN:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_IN:
                                $operator = 'IN';
                                break;
-                       case self::OPERATOR_NOT_IN:
-                               $operator = 'NOT IN';
-                               break;          
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO:
                                $operator = '=';
                                break;
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_NOT_EQUAL_TO:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_NOT_EQUAL_TO:
                                $operator = '!=';
                                break;
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_LESS_THAN:
                                $operator = '<';
                                break;
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_LESS_THAN_OR_EQUAL_TO:
                                $operator = '<=';
                                break;
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_GREATER_THAN:
                                $operator = '>';
                                break;
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO:
                                $operator = '>=';
                                break;
-                       case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE:
+                       case Tx_Extbase_Persistence_QueryInterface::OPERATOR_LIKE:
                                $operator = 'LIKE';
                                break;
                        default:
@@ -607,7 +645,7 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend implements Tx_Extbase_Persis
                        if ($markPosition !== FALSE) {
                                if ($parameter === NULL) {
                                        $parameter = 'NULL';
-                               } elseif (is_array($parameter)) {
+                               } elseif (is_array($parameter) || ($parameter instanceof ArrayAccess) || ($parameter instanceof Traversable)) {
                                        $items = array();
                                        foreach ($parameter as $item) {
                                                $items[] = $this->databaseHandle->fullQuoteStr($item, 'foo');
index 11bf935..797ea06 100644 (file)
@@ -67,6 +67,9 @@ class Tx_Extbase_Persistence_Value implements Tx_Extbase_Persistence_ValueInterf
        public function getString() {
                if ($this->value === NULL) return NULL;
                if (is_array($this->value)) return $this->value;
+               if ($this->value instanceof Tx_Extbase_DomainObject_AbstractDomainObject) {
+                       return (string)$this->value->getUid();
+               }
 
                switch ($this->type) {
                        case Tx_Extbase_Persistence_PropertyType::DATE:
index b013562..657efce 100644 (file)
@@ -35,23 +35,23 @@ class Tx_Extbase_Persistence_Storage_Typo3DbBackend_testcase extends Tx_Extbase_
        public function providerForBasicComparison() {
                return array(
                        'equal' => array(
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_EQUAL_TO,
                                "SELECT table_name_from_selector.* FROM table_name_from_selector WHERE table_name_from_property.foo = 'baz'"
                                ),
                        'less' => array(
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN,
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_LESS_THAN,
                                "SELECT table_name_from_selector.* FROM table_name_from_selector WHERE table_name_from_property.foo < 'baz'"
                                ),
                        'less or equal' => array(
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_LESS_THAN_OR_EQUAL_TO,
                                "SELECT table_name_from_selector.* FROM table_name_from_selector WHERE table_name_from_property.foo <= 'baz'"
                                ),
                        'greater' => array(
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN,
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_GREATER_THAN,
                                "SELECT table_name_from_selector.* FROM table_name_from_selector WHERE table_name_from_property.foo > 'baz'"
                                ),
                        'greater or equal' => array(
-                               Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO,
+                               Tx_Extbase_Persistence_QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO,
                                "SELECT table_name_from_selector.* FROM table_name_from_selector WHERE table_name_from_property.foo >= 'baz'"
                                ),