[TYPO3-mvc] sort queryResult in code, not database

Sebastian Fischer sf at marketing-factory.de
Mon Jan 3 11:00:10 CET 2011


On 31.12.2010 13:48, Moritz Bützer wrote:
> Hi there,
>
> we have a query that runs for around 2 minutes if we sort and group it in
> mysql (lot's of joins, etc.)
> we try to solve this problem by sort and group our result set (which is
> pretty small) in code.
>
> In our Tx_Extbase_Persistence_Repository we get a QueryResult using
> $query->execute()
>
> The paginate widget only accepts QueryResult object so we have to return one
> of these object to the view.
> What we can't figure out though, is how to create a differently sorted
> QueryObject than the one we got from our acctual query.
>
> Any ideas on that? (we know of course that we should sort it in mysql. we
> really would if we could ;-))
>
>
> Thanks a lot
> Moritz
>

Hi Moritz,

just some untested ideas:

1. get all results of your queryResult returned from the repository.

2. sort it with any php method you like.

3. extend the Tx_Extbase_Persistence_QueryResult with an empty __construct

4. add a setter for $queryResult that accepts an array

5. set the result with the sorted array.

6. use the "pimped" queryResult in fluid to satisfy the paginate widget.

7. advanced to the next coding problem ;)

Greetings
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list