[TYPO3-mvc] Left join query
Felix Oertel
typo3 at foertel.com
Thu May 27 11:51:44 CEST 2010
Hey
On 2010-05-27 11:32:55 +0200, Daniel Dimitrov said:
> Come on guys, I think that this really deserve at least a small
> explanation or a nice tutorial :)
ok, small answer: you don't need join queries ;)
> "Daniel Dimitrov" <danielsd_bg at yahoo.fr> wrote in message
> news:mailman.1.1274346762.31732.typo3-project-typo3v4mvc at lists.typo3.org...
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.
there's a mm-relation between your products and your keywords. first
you have to make sure that extbase can follow this relation in both
directions (means products have a field "keywords" with MM set and
keywords have a field "products" with MM and (!) MM_oposite_field (to
"keywords") set [*])
if you want to search for all products containing a keyowrd you just
fetch the keyword-model via the keyword-repository (with
matching(like($searchphrase)) or similar and then do
$keyword->getProducts() as extbase mapps all products containing this
keyword-model into that property itself ;-) Why do you want to join
yourself? Extbase loves you and takes care for everything *g
regards, foertel
PS: if you really want to get the products yourself (which hardly makes
sense, cause you have to get the keyword-model upfront anyway) you can
do something like products=>matching(contains('keywords',
$keywordModel)) ... extbase won't build a join for you but use a
subselect in SQL's IN() - the result is the same (at least the
resultSET is *g)
[*] if anyone is confused by this I suggest to take a look at all
fields starting with MM_ at
http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.1.0/view/4/2/#id4224554
More information about the TYPO3-project-typo3v4mvc
mailing list