[TYPO3-mvc] documentation, and example exbase m:n relation query

Anja Leichsenring aleichsenring at ab-softlab.de
Sun Jun 29 16:53:25 CEST 2014


Hi Muriel,

not possible using API. Use plain SQL.

Regards Anja

On 29.06.2014 14:19, Muriel le Pair wrote:
> 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