[TYPO3-mvc] MM (many to many) how to tca.php

Cornelius Illi cornelius.illi at student.hpi.uni-potsdam.de
Fri Apr 30 20:02:25 CEST 2010


DataMapper.php #352
$constraint = $query->equals($columnMap->getParentKeyFieldName(), 
$parentObject );
Does not seem like I have any chance to do so without altering the core.



Am 30.04.2010 18:35, schrieb Cornelius Illi:
> Hi Franz,
>
> thanks for your support. I was able to get everything running. Except
> that I need to do the following and I don't know how do change it.
> The generated SQL looks like this at the moment:
>
> |LEFT  JOIN  tx_xx_domain_model_staat  ON  tx_xx_unternehmen_staat_mm.uid_foreign  =  tx_xx_domain_model_staat.uid
> WHERE  tx_xx_unternehmen_staat_mm.uid_local  =  '<this.uid>'  ORDER  BY  tx_xx_unternehmen_staat_mm.sorting  ASC
> |
>
> The<this.uid>  should actually be<this.unternehmen_nr>. Didn't find
> anything on how to do that. Cannot do it using the uid field as we
> synchonrize the data from a clients database.
> Cheers,
>
> Cornelius
>
>
>
> Am 30.04.2010 17:21, schrieb Franz Koch:
>    
>> Hey Cornelius,
>>
>>
>>      
>>> TCA.php
>>> ================================
>>> 'columns' =>   array(
>>> 'countries' =>   array(
>>> 'config' =>   array (
>>> 'type' =>   'inline',
>>> 'foreign_class' =>   'Tx_xx_Domain_Model_Staat',
>>> 'foreign_table' =>   'tx_xx_domain_model_staat',
>>> 'MM' =>   'tx_xx_domain_model_unternehmen_staat_mm',
>>> 'MM_match_fields' =>   array(
>>> "nr" =>   'tx_xx_domain_model_staat',
>>> "unternehmen_nr" =>   'tx_xx_domain_model_unternehmen'
>>> ),
>>>
>>> )
>>> ),
>>> ================================
>>>
>>>        
>> Please have a look at the TYPO3 documentation [1] for how to
>> configure/use MM_match_fields - it seems like you've got a wrong picture
>> from it.
>>
>> With MM_match_fields and MM_insert_fields (you need both) you can tell
>> TYPO3 which additional data should be stored in the MM table in order to
>> identify the relations to different tables as soon as you use one MM
>> table for relations to multiple other tables (like DAM does).
>> It does not insert values from fields or objects there, but simply the
>> plain text value you defined in your configuration. So having this
>> configuration:
>>
>>
>>      
>>> 'MM_match_fields' =>   array(
>>>      "nr" =>   'tx_xx_domain_model_staat',
>>>      "unternehmen_nr" =>   'tx_xx_domain_model_unternehmen'
>>> ),
>>>
>>>        
>> Typo3 will look for MM relations, where the MM table has the value
>> "tx_xx_domain_model_staat" in it's field "nr" and the value
>> "tx_xx_domain_model_unternehmen" in it's field "unternehmen_r". As long
>> as you don't add those values via MM_insert_fields, your quieries will
>> alway return a empty result. The SQL definition of your MM table would
>> have to look like this:
>>
>> CREATE TABLE tx_xx_domain_model_unternehmen_staat_mm (
>> 	uid_local...,
>> 	uid_foreign...,
>> 	nr...,
>> 	unternehmen_nr...,
>> 	sorting
>> );
>>
>>
>> But as it seems, you're only using the MM-table for a relation between 2
>> tables, so simply drop the "MM_match_field" part in your TCA
>> configuration and everything should work as expected.
>>
>>
>>
>> [1]
>> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.3.0/view/4/2/#id2522688
>> (scroll down to the MM part)
>>
>>      
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>    



More information about the TYPO3-project-typo3v4mvc mailing list