[TYPO3-mvc] Properties from related objects with M:M

Jochen Rau jochen.rau at typoplanet.de
Thu Mar 25 10:56:29 CET 2010


Hi Pascal.

On 19.03.10 11:28, Pascal Jungblut wrote:
> I've been paying around with the nice new feature #6755 (Implement a way to access properties from related objects in comparisons) using r2072. It works perfect for 1:1 relations, but there seem to be a problem when a property of another property is an M:M relation.
> Let's assume I have a letter, a mailinglist for that letter and many recipients on that mailinglist (mailinglist<-- m:m -->  recipient). Now, if I'm in the LetterRepository and try to fetch every letter with a recipient $recipient, I'd like to do the following:
>
> $query->equals('mailinglist.recipient', $recipient)
>
> But that returns an empty array. Is this a bug, err hidden feature, or do I have to modify my query?

Your query is perfectly right. But you might want to drop your 
intermediate table and use a "foreign_table" without a "foreign_key" 
defined. this results in a comma separated list in the "recipient" field 
but with only one item.

Of course Extbase should fully support n:1-relations with intermediate 
tables, too. It is currently scheduled for Extbase 1.2.0beta1.

Background: I have implemented the detection of the type of relation at 
a point in time where Reflection part of FLOW3 wasn't available in 
Extbase. So, I had to parse the TCA to detect the type. But there is a 
difference between the type of relation and the way how this relation is 
stored in the database. ATM Extbase don't differentiate the both.

types of relation:
1. has one (1:1)
2. has many (1:n)
3. has and belongs to many (m:n)
4. belongs to many (n:1) (not implemented, yet)

technical solution:
a) csv
b) foreign key
c) intermediate table

Sinful combination (not recommended: (x) ):
1 + a/b
2 + (a)/b
3 + (a)/c
4 + a/c (a with only one item)

> Also: is there any way to get the actual SQL-statement that extbase used?

ATM you have to uncomment the existing debug statements in the 
TYPO3DbBackend.

Regards
Jochen


More information about the TYPO3-project-typo3v4mvc mailing list