[TYPO3-irre] can I use a table twice
Oliver Hader
oh at inpublica.de
Mon Aug 6 20:03:42 CEST 2007
Hi Ulrich,
Ulrich Fischer schrieb:
> #
> # Table structure for table 'tx_irretutorial_mnasym_offer'
> #
> CREATE TABLE tx_irretutorial_mnasym_offer (
> hotels int(11) DEFAULT '0' NOT NULL,
> );
>
> I do not really understand what role this hotels field plays?
In this case, the field 'hotels' is defined of type 'inline' and is the
entry point/handler for direct related child records. In the database
table the field 'hotel' will get the number of related records. Thus, if
you related nine offers to that one hotel, the field 'hotels' will have
a "9" as integer.
> I want to use the table tx_irretutorial_mnasym_offer twice
> (in my case it is a table with all countries in the world).
> Is it possible to use it twice, and is it necessary to
> have new int-field for the second connection?
>
> for example:
> CREATE TABLE tx_irretutorial_mnasym_offer (
> uid int(11) NOT NULL auto_increment,
> ...
> hotels int(11) DEFAULT '0' NOT NULL,
> events int(11) DEFAULT '0' NOT NULL,
> ...
> );
The more interesting thing is the tca.php. Do you want to use the child
table on one parent record twice? This isn't possible at the moment, see
also a feature request for it: http://bugs.typo3.org/view.php?id=5897
If you want to use different parent tables it is possible using the
'foreign_table_field' property in $TCA, e.g.
$TCA['first_parent_table']['columns']['offers'] = array(
'type' => 'inline',
'foreign_table' => 'offer_child_table',
'foreign_table_field' => 'parent_name',
'foreign_field' => 'parent_uid',
);
$TCA['second_parent_table']['columns']['otheroffers'] = array(
'type' => 'inline',
'foreign_table' => 'offer_child_table',
'foreign_table_field' => 'parent_name',
'foreign_field' => 'parent_uid',
);
Thus, on the child side the field 'parent_uid' is filled with the uid of
the parent record and the field 'parent_table' is filled with the name
of the parent table (e.g. 'first_parent_table' or 'second_parent_table'
in this example).
> Thank you for bringing the light
I hope I succeeded... ;-)
olly
--
Oliver Hader
http://inpublica.de/
More information about the TYPO3-project-irre
mailing list