[TYPO3-mvc] query for objects with at least one category

Dmitri Pisarev dimaip at gmail.com
Mon Jun 20 19:51:25 CEST 2011


Hey!
Once again I'm stuck...
I need to write a query, that shall select all of the objects (with any 
pid, $query->getQuerySettings()->setRespectStoragePage(FALSE);), that 
have at least one category assigned (Categories only from storagePid).
The only way which I could think out was 
$query->matching($query->in('category', $categories)); where $categories 
I have to pass to repository action. Not convinent and didn't work right 
away.

The other solution would if I could temporary use category field of 
tt_news as simple int, instead of as a relation, e.g I need this query 
SELECT * FROM tt_news where category > 0
But how do I do it? Set a custom mapping for this field, and map it to a 
custom property like category_count? Will this work?
Any better advice?

Sorry for being silly and annoying!
Regards,
Dmitri.


PS:I use the tables from tt_news:
config.tx_extbase{
	persistence {
		classes {
Tx_Lister_Domain_Model_Article.mapping.tableName = tt_news 
Tx_Lister_Domain_Model_Category.mapping.tableName = tt_news_cat
		}
	}
}


More information about the TYPO3-project-typo3v4mvc mailing list