[TYPO3-mvc] AVG, SUM in Repository

Stefan Frömken firma at sfroemken.de
Mon Jan 30 17:30:00 CET 2012


Hello MVC-List,

has anybody an idea how to create a SUM or AVG Query in Repository?

OK...I can query on my own with $query->statement, but the result is 
always empty. I think that is because of method: >>parseQuery<< where 
fields will be set to >>$table . '*'<<. So something like >>SUM(field)<< 
will never work.

Further I tries to modify Tx_Extbase_Persistence_Query:
config.tx_extbase {
	objects {
		Tx_Extbase_Persistence_Query {
			className = Tx_KeZr_Persistence_Query
		}
	}
}

But in Frontend following appears:
Fatal error: Call to undefined method 
Tx_Extbase_Persistence_Query::sum() in 
/var/www/typo3_45/typo3conf/ext/myExt/Classes/Domain/Repository/InvoiceRepository.php 
on line 33
Does my TS don't works with this class?

I can do a
$GLOBALS['TYPO3_DB']->sql_query('SELECT SUM(col) FROM table');
because I need the where clause of the repository. The user can change 
the amount of records or filter them...so...how to get the current where 
clause out of the repository?

Maybe you have some better ideas?

Stefan


More information about the TYPO3-project-typo3v4mvc mailing list