[TYPO3-english] Extbase 1.3 - Repository API for SQL group by

Rayuth You rayuth.you at gmail.com
Fri Apr 29 05:10:04 CEST 2011


Hi all,

On Typo3 4.5, I wanna write this below statement into repository API.

My Query:
SELECT profile.*, statistic.view_count
FROM statistic
JOIN profile ON statistic.profile = profile.uid
WHERE profile.sys_language_uid = ' . $language . '
GROUP BY statistic.profile
ORDER BY statistic.view_count DESC
LIMIT '. $limit

I write into repository API:
$query->matching($query->equals('sys_language_uid', $language))
			->setOrderings(array('statistic.view_count' => 
Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING))
			->setLimit($limit)
			->execute();

I got this error:
#1247602160: You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right syntax to use 
near 'ON (FIND_IN_SET(.uid, tx_wetwdb_domain_model_profile.statistic)) 
WHERE tx_wetwdb' at line 1: SELECT DISTINCT 
tx_wetwdb_domain_model_profile.* FROM tx_wetwdb_domain_model_profile 
LEFT JOIN ON (FIND_IN_SET(.uid, 
tx_wetwdb_domain_model_profile.statistic)) WHERE 
tx_wetwdb_domain_model_profile.sys_language_uid = '0' AND 
tx_wetwdb_domain_model_profile.deleted=0 AND 
tx_wetwdb_domain_model_profile.hidden=0 AND 
(tx_wetwdb_domain_model_profile.starttime<=1304045340) AND 
(tx_wetwdb_domain_model_profile.endtime=0 OR 
tx_wetwdb_domain_model_profile.endtime>1304045340) AND 
tx_wetwdb_domain_model_profile.sys_language_uid IN (0,-1) AND 
tx_wetwdb_domain_model_profile.pid IN (4) ORDER BY view_count DESC LIMIT 10

The idea is: To count view_count of each profile by language.
Is possible to do this? If possible, how/what need I do?

Thanks,
Yuth


More information about the TYPO3-english mailing list