/** * Transforms orderings into SQL. * * @param array $orderings An array of orderings (Tx_Extbase_Persistence_QOM_Ordering) * @param Tx_Extbase_Persistence_QOM_SourceInterface $source The source * @param array &$sql The query parts * @return void */ protected function parseOrderings(array $orderings, Tx_Extbase_Persistence_QOM_SourceInterface $source, array &$sql) { foreach ($orderings as $propertyName => $order) { switch ($order) { case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_ORDER_ASCENDING: // Deprecated since Extbase 1.1 // Deprecated since Extbase 1.1 case Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING: $order = 'ASC'; break; case Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_ORDER_DESCENDING: // Deprecated since Extbase 1.1 // Deprecated since Extbase 1.1 case Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING: $order = 'DESC'; break; default: throw new Tx_Extbase_Persistence_Exception_UnsupportedOrder('Unsupported order encountered.', 1242816074); } if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) { $className = $source->getNodeTypeName(); $tableName = $this->dataMapper->convertClassNameToTableName($className); while (strpos($propertyName, '.') !== FALSE) { $this->addUnionStatement($className, $tableName, $propertyName, $sql); } } elseif ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) { $tableName = $source->getLeft()->getSelectorName(); } $columnName = $this->dataMapper->convertPropertyNameToColumnName($propertyName, $className); if (strlen($tableName) > 0) { $sql['orderings'][] = $tableName . '.' . $columnName . ' ' . $order; } else { $sql['orderings'][] = $columnName . ' ' . $order; } } }