[TYPO3-mvc] Setting ordering has no effect?
Jochen Rau
jochen.rau at typoplanet.de
Sun Jul 12 05:03:57 CEST 2009
Hi.
Joerg Schoppet wrote:
> I implemented the following method within my own Repository-Class:
>
> public function getOrdered() {
> $query = $this->createQuery();
> $query->setOrderings(array('name' =>
> Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING));
Unfortunately, building Orderings is not as straight forward as you
expected. You have to specify it like this:
$orderings[] = $this->QOMFactory->ascending($aDynamicOperand);
$query->setOrderings($orderings);
Maybe we should implement a delegating method in the repository to ease
the handling.
> $result = $query->execute();
> $this->persistenceManager->getSession()->registerReconstitutedObjects($result);
>
> return $result;
> }
>
> Have I done something wrong, or is actually the content of the
> orderings-field not taken into account?
>
> What I have done now to implement it is changing Typo3DbBackend.php:
>
> in function parseSource() I added in the first if-statement:
> foreach ($query->getOrderings() as $field => $order) {
> $sql['orders'][] = $field . ' ' . $order;
> }
>
> and in function getRows() I added before the replacePlaceholders-call:
> if (!empty($sql['orders'])) {
> $sqlString .= ' ORDER BY ' . implode (', ', $sql['orders']);
> }
>
>
> Is this ok this way? Should I open a bug-/feature-request?
I have already started to implement this feature. So, it is only a
matter of weeks ;-).
Jochen
--
Every nit picked is a bug fixed
More information about the TYPO3-project-typo3v4mvc
mailing list