[TYPO3-mvc] documentation, and example exbase m:n relation query
Muriel le Pair
typo3 at strangefruit.nl
Sun Jun 29 14:19:16 CEST 2014
Anja Leichsenring schreef op 29-06-14 13:34:
> you don't need to care about the character of any multi dimensional
> relations using extbase.
>
> If your model contains such a relation, it is represented by
> ObjectStorages. Then you ask the repository about the model and use the
> getter to retrieve the child object, which contains many instances of
> the child model.
>
> It is essential that your TCA correctly sets up the multi dimensional
> relationship!
>
> like this (pseudo code):
>
> class A extends AbstractEntity {
>
> /**
> * @var ObjectStorage<Model B>
> */
> $children;
>
> public function getChildren() {
> return $this->children();
> }
>
> in your controller you call
> $a = $Arepository -> findByUid(42);
> then you can do
> foreach ($a->getChildren() as $child) {
> $child->getName();
> }
>
> Nothing else you need, and there is no difference in handling of 1:n and
> n:m relations.
Hi Anja,
Thanks for your help.
How do select on a n:m relation. So for instance select all records
where n:m relation child.uid=1?
(so in plain sql it would be something like:)
SELECT * from table1
LEFT JOIN mmtable ON table1.uid = mmtable.uid_local
WHERE mmtable.uid_local =1
--
kind regards,
Muriel le Pair
More information about the TYPO3-project-typo3v4mvc
mailing list