[TYPO3-mvc] extbase: relations simple question

Christine Gerpheide cgerpheide at gmail.com
Mon Feb 15 21:15:12 CET 2010


In kickstarter you only need to add "projects" inside of the Client object
(and then connect it with the little wire to the Project model).  In the
database, this will create a "client" uid field inside of the project table.
 More importantly, though, it will create the property "projects" inside of
the Client model class (along with getProjects()/setProjects()), which as I
said before I think is the appropriate way of retrieving projects for a
client.

Does this answer your question?
Christine

2010/2/15 Dmitri Pusarev <dimaip at gmail.com>

> 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.
>>>>
>>> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>


More information about the TYPO3-project-typo3v4mvc mailing list