[TYPO3-mvc] extbase: relations simple question

Dmitri Pusarev dimaip at gmail.com
Mon Feb 15 20:58:39 CET 2010


Thanks Thomas and Christine!

Thomas "Thasmo" Deinhamer wrote:
> You can of course use both ways, if you like:
> 
> $projects = $client->getProjects();
> $client = $project->getClient();
Yeah, but to use it both ways I need to create relationships in both 
ways, right? Which is both a) and b), answering my first question.
a)Client has a relation projects with Project, 0..*(fk).
b)Project has a relation client with Client, 0..1.

It looks very weird in the kickstarter when creating relations both 
ways. The only alternative to this is crearing only "a)Client has a 
relation projects with Project, 0..*(fk)." Then this is what works:
$projects = $client->getProjects();
$client = $this->clientRepository->findByProject($project);
Which is again kind of ugly.

Plus in the kickstarter when I create both relations, it duplicates the 
client field in ext_tables.sql and in tca.php:
"client int(11) unsigned DEFAULT '0'
client int(11) unsigned DEFAULT '0'"
Which makes me doubt this is the correct way of doing things.

So once again, please answer my first question, is it really the best 
approach to create two relations for each pair of objects? It feels 
right, but in kickstarter it just looks messy... For example in IBM 
rational modeler things are much more simple: you just define on every 
edge of a link its name and multitude. In this example it would look 
like: Client(projects 0..1)<---->Project(0..* client)


> 
> Greatings,
> Thomas
> 
> Am 15.02.2010 19:49, schrieb Dmitri Pusarev:
>> OK, I think I can make my question more specific:
>> a) $projects = $client->getProjects();
>> b) $this->projectRepository->findByClient($client);
>> Which is better to get all projects for given client, a) or b)?
>>
>>
>> Dmitri Pusarev wrote:
>>> Hey!
>>> In my model I have a Client and a Project. Relations which pop into my
>>> mind from the business domain:
>>> a)Client has a relation projects with Project, 0..*(fk).
>>> b)Project has a relation client with Client, 0..1.
>>> Should I create both a) and b)? Or just a) is enough?
>>>
>>> In the database language(which I more used to), I would just create a
>>> field 'client' in the table 'Projects'.
>>>
>>> Sorry, I'm still learning!
>>>
>>> Cheers,
>>> Dmitri.


More information about the TYPO3-project-typo3v4mvc mailing list