[TYPO3-mvc] Conceptual Question with RELATION_HAS_ONE

Sebastian Fischer sebastian at fischer.im
Wed Jul 1 09:01:25 CEST 2009


Jeff Segars schrieb:
> Hey guys,
> I know things are in a bit of flux with all the persistence work 
> underway but I wanted throw out what is probably an obvious question on 
> a simple field with RELATION_HAS_ONE.
> 
> Inside the extbase test cases, 
> Tx_Extbase_Persistence_Mapper_DataMap_testcase contains a TCA definition 
> for a blog author that references an author table rather than just being 
> an input field as it is in blog_example. Since it's already in the test 
> case, seems like a good example for my question :)
> 
>> 'author' => array(
>>     'exclude' => 1,
>>     'label'   => 
>> 'LLL:EXT:blog_example/Resources/Language/locallang_db.xml:tx_blogexample_domain_model_blog.author', 
>>
>>     'config' => array(
>>         'type' => 'select',
>>         'foreign_class' => 'Tx_BlogExample_Domain_Model_Author',
>>         'foreign_table' => 'tx_blogexample_domain_model_author',
>>         'maxitems' => 1,
>>     )
>> ),
> 
>  From what I can see of the persistence framework (both in trunk and in 
> persistence rewrite) it expects that this simple relation also provides 
> a foreign_field and foreign_table field so that the relation is saved in 
> the child table rather than the parent table.
> 
> This of course doesn't match the blog model that would allow the same 
> author to be assigned multiple blogs and doesn't work with the backend 
> select type that saves a UID directly in the parent table.
> 
> It seems like I must be missing something obvious here so if anyone can 
> enlighten me, it would be greatly appreciated ... and if the answer is 
> "I'm busy...wait for the persistence rewrite to get done and it will all 
> work" that's perfectly fine too ;)
> 
> Thanks,
> Jeff

Hi Jeff,

i guess, but i expect to have one answer here, "take a mm relation", but 
i agree with you, it should be possible to store the authers id in the 
blog model and not always store the blog in the author. So it should be 
possible to get it work without the foreign_table field in the author model.

As seen in http://en.wikipedia.org/wiki/File:ERD_Representation.svg the 
Chen notain could go with an extra table birthplace, but like in IDEF1X 
is also possible to store the place id in the persons dataset.

Greetings
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list