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

Cornelius Illi cornelius.illi at student.hpi.uni-potsdam.de
Fri Apr 30 16:54:46 CEST 2010


Hi there,

i am stuck with setting up a many-to-many relation. What I need is a 
M-M-Relation between a Company.CompNr <-> Country.Nr
What I got so far:

Model.php:
================================
     /**
      * @var 
Tx_Extbase_Persistence_ObjectStorage<Tx_CiPlanerDb_Domain_Model_Staat>
      * @lazy
      */
     protected $countries;

     public function __construct() {
         $this->countries = new Tx_Extbase_Persistence_ObjectStorage();
     }

     public function getCountries() {
         return $this->countries;
================================

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'
                 ),

           )
   ),
================================

I think the problem is that the mapping via 'MM_match_fields' does not 
fit!?
Anything else that I might have forgotten? Is there a tutorial on 
object-relations out there? The blog_example uses the uid fields, 
therefore only 'MM' needs to be set.

ext_tables.sql
================================
CREATE TABLE tx_xx_unternehmen_staat_mm (
     uid_local int(11) unsigned DEFAULT '0' NOT NULL,
     uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,

     KEY uid_local (uid_local),
     KEY uid_foreign (uid_foreign)
);
================================

Thanks for your advise. Cheers,
Cornelius



More information about the TYPO3-project-typo3v4mvc mailing list