[TYPO3-mvc] How to get calculated data from a query into an object?

Martin Kutschker masi-no at spam-typo3.org
Wed Feb 17 14:20:39 CET 2010


Franz Koch schrieb:
> Hi,
> 
>> Depends on the method you use to calculate the disctance
> 
> I calculate the distance based on latitude and longitude of both, the
> visitors location and the stores address (geolocating).
> 
>> I would introduce a virtual property by adding a getter to the model
>> returning the calculated distance
>> Is this an option?
> 
> I would need a service then for this, which I first have to pass the
> visitors location/coordinates somehow because the store does not know
> about those. This would probably work, but as I wrote I'm trying to
> avoid double calculations, as the DB has to do the calculation anyway.

Perhaps you can create a special method for your store repository that executes the query to
retrieve store rows with the calculated distances.

It would then call directly mapSingleRow() or map() of the DataMapper class.

Then you can put your store objects together with the distance data into the transient object or
array. I would not add the distances to the stores even only in memory. The distance does not belong
to a store.

Masi


More information about the TYPO3-project-typo3v4mvc mailing list