[TYPO3-mvc] Left join query

Daniel Dimitrov danielsd_bg at yahoo.fr
Thu May 20 11:08:35 CEST 2010


Hey guys,
I know that there are several posts about that, but I really cannot 
understand them.

I was looking at datamapper->getPreparedQuery, but I cannot figure out how 
to use this in my example.

I have a productobject, that can have multiples keywords.
Product object is stored in - tx_bwshop_domain_model_products
I have an mm relation table tx_bwshop_keywords_mm
And the keywords table tx_bwshop_domain_model_keywords

When I'm showing a list with all products, then extbase make some magic 
tricks and I can see all the keywords for a product :)

The thing is that I have a search mask where I can search for a keyword and 
I have to show all products for this keyword and its children.

Here is how the query normally looks:

$sql =	' SELECT '.
	'tx_bwshop_domain_model_products.* '.
	' FROM tx_bwshop_domain_model_products'.
	' LEFT JOIN tx_bwshop_keywords_mm ON tx_bwshop_keywords_mm.uid_local = 
tx_bwshop_domain_model_products.uid' .
	' WHERE '.
                ' tx_bwshop_keywords_mm.uid_foreign IN ('.implode(',', 
array_keys($kws)).') ';

$kws here is an array that contains all the children of a parent keyword 
like this:
Parent keyword
-- child keyword
-- child keyword
--- child child keyword

The only way I found to get my sql executed was:
$query->statement($sql)->execute();

I would really like to know how to make this left join the extbase way :)
Any help is appreciated!
 



More information about the TYPO3-project-typo3v4mvc mailing list