[TYPO3-mvc] Other direction in relation between 1:N

Pankaj Lele pankaj at lelesys.com
Wed Aug 10 06:19:28 CEST 2011


Hi Lars,

> I have created a new Extension with several Models with the Extbase
> Extension Builder. ModelA has a 1:n Relationshop to ModelB. It is easy
> to get all ObjectBs from ObjectA, but how can I get the ObjectA of ObjectB?
> 
> I can not find anything in the code of ModelB. Is there a default
> function or do I have to implement a function for this?

You can define a property $objectA which is of type
Tx_YourKey_Domain_Model_ObjectA and get/set methods. With 1:n relation
you must see a field as "objecta" in tx_yourkey_domain_model_objectb table.

I always do this when there is a need to get the parent of the child
object. It works but not sure if it's a elegant way. Same thing is seen
in blog_example so for now I can believe it might be ok :)

-Pankaj

-- 

With best regards,
Pankaj Lele
---------------------------

CTO & Executive Director
Lelesys Infotech Pvt. Ltd.
Pune/Goa, India

Web: http://www.lelesys.com

[Certified TYPO3 Integrator]


More information about the TYPO3-project-typo3v4mvc mailing list