[TYPO3-mvc] How to get calculated data from a query into an object?
Franz Koch
typo3.RemoveForMessage at elements-net.de
Wed Feb 17 20:37:54 CET 2010
Hi guys,
>> 1) Should be fairly straightforward. From the repository you can
>> execute any SQL query you want.
> In order to annul the data mapper (for later manual processing)
> it would be necessary to either fire a low level query directly or
> manipulate
> querySettings->returnRawQueryResult and use $query-statement...
Or simply do it quick and dirty the old way with direct calls to
TYPO3_DB (that's what I did due to lack of time, see below)
> For the distance/store case I would say:
> If you don't need the distance as a query criteria you could even use a
> simple findBy
> with having returnRawQueryResult set.
>
> Franz: do you need the distance as query criteria?
yes, of course. I need to get only stores back within a given distance
to the users location. Otherwhise I could do the calculation stuff only
in a service. But as I mentioned I need to calculate the distance for
the query anyway, so I was looking for a way to reuse the already
calculated data in a easy way.
>> 2) Needs digging into ExtBase. I think you can get hold of the mapper
>> object(s). If you've got it,
>> you must only call the mapSingleRow() method. I can look it up in the
>> evening.
>
> Yes, after some short diggin I would say: seems to be a viable way :).
As for mapping query results by hand in the repository, have a look at
what I do almost since I started using extbase as I need complex joins
for almost every query/request to the repository and make use of direct
calls of TYPO3_DB for various reasons (at least for now):
http://pastebin.com/m2778270a
As you might notice I've implemented a flag "enableResultCount". With
this I can count the total results and still only get a subset back in
one go without a second query counting the results. I implemented this
for pagination purposes etc. and hope it's faster then firing a second
query.
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list