[TYPO3-english] Correct use of tablenames field in mm tables

Guillermo R. Oramas J. oramas.g at gmail.com
Mon Jun 20 15:43:35 CEST 2011


Hello Jigal.

Thank you for your very well explained answer.

You said:

> Although it can work the column tablenames is usually meant for a different situation:

I still don't understand why my example doesn't match the purpose for
which the tablenames column was done.


2011/6/18 Jigal van Hemert <jigal at xs4all.nl>:
> Hi,
>
> On 17-6-2011 18:48, Guillermo R. Oramas J. wrote:
>>
>> Like an example I have these three tables: customers, suppliers and
>> countries.
>
> [...]
>>
>> I understand this:
>> The first row means that supplier1 is in germany.
>> The second row means that customer1 is also in germany.
>
> Although it can work the column tablenames is usually meant for a different
> situation:
>
> There are three kinds of clients, each has its own table (because some
> fields are different):
> - tx_myext_persons
> - tx_myext_companies
> - tx_myext_organisations
>
> There is also a table of lawyers and you need to store which clients are
> represented by a lawyer:
> - tx_myext_lawyers
>
> - tx_myext_mm_lawyers_clients
>
> In this last table lawyer with uid=3 has clients:
> - 3 (person), 4 (person)
> - 3 (company),
> - 5 (organisation)
>
> In tx_myext_mm_lawyers_clients this is stored as:
> uid_local | uid_foreign | tablenames
> 3 | 3 | tx_myext_persons
> 3 | 4 | tx_myext_persons
> 3 | 3 | tx_myext_companies
> 3 | 5 | tx_myext_organisations
>
> So it's a relation of one field with records from more than one table.
>
>> But I already have doubts:
>> ¿Is it necessary some TCA configuration in order to TYPO3 understand
>> the relations?
>
> Yes, look at the TCA documentation of the 'group' type [1].
> internal_type must be 'db'
> allowed must list the tables which can be linked
> (tx_myext_persons,tx_myext_companies,tx_myext_organisations)
> MM must contain the name of the mm-table
>
> The documentation of the 'select' type [2] also provides good information.
>
>> ¿Is possible to setup it from Kickstarter?
>
> To some extend, yes. If you select 'True MM relations' and select 'all
> tables' for the table you link the data from the kickstarter will set:
> allowed => '*',
>
> You can change that later to the desired tables. But at least the mm-table
> is generated, etc.
>
>> ¿Is necessary to set an index for the tablenames field?
>
> If there are loads of relations it can speed up queries.
>
> [1]
> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.3.0/view/4/2/#id2525241
> [2]
> http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.3.0/view/4/2/#id2522688
>
> --
> Kind regards / met vriendelijke groet,
>
> Jigal van Hemert.
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english


More information about the TYPO3-english mailing list