[TYPO3-mvc] Tx_Extbase_Persistence_ObjectStorage problem
Michael Knoll
mimi at kaktusteam.de
Tue Jan 5 03:16:13 CET 2010
Hi Sebastian,
hm - you are right and wrong I think. First - if you do it like in your
suggestion, you have multiple db-queries. But if you use a join, you
will be about to have the same workload in your database as if using the
"in" operator.
But there are other reasons, why you should not rely on comma-separated
lists:
1. No efficient index structures can be created on them
2. No foreign key constraints can be used on them
3. You break the first rule of relational db design: atomic values in
fields :-)
The 3. point is not really relevant, whereas 1 and 2 are quite important.
Don't ask me, how to do a JOIN in ExtBase (I know it works, but dunno
how), but you really should get rid of comma separated lists - they
stink :-)
Greetings
Michael
Sebastian Schreiber schrieb:
> Hi Michael,
> basically i agree with you.
> In most cases i also would use real MM-Tables instead of comma-separated
> lists.
>
> But in some cases it is necessary to cope with comma-separated lists.
> But how can you achieve this with Extbase.
> Is there any possibility to get i.e. all articles with one "Call"?
> In straight DB-Syntax it would look like this:
> $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table, 'uid IN
> (t3lib_db::cleanIntList($list))'
>
> I created the following workaround.
> For me it is a workaround, because you have to do multiple db-requests
> instead of one (Bad performance).
> I know this issue. I had the same question before with Propel/Doctrine
> in Symfony.
>
> /**
> * Find only defined articles by uids
> *
> * @param string $list
> * @param integer $limit
> * @return array The array of articles
> */
> public function findTopArticles($list, $limit = 3)
> {
> $cleanArray = t3lib_div::trimExplode(',',
> t3lib_db::cleanIntList($list));
>
> $objects =
> t3lib_div::makeInstance('Tx_Extbase_Persistence_ObjectStorage');
>
> foreach($cleanArray as $key => $value)
> {
> $object = $this->findByUid((integer)$value);
> $objects->attach($object);
> }
>
> return $objects;
> }
>
>
> Thanks
>
> Sebastian
>
>
> Michael Knoll schrieb:
>> Hi Dimanche,
>>
>> in my opinion, you should not use comma seperated lists as a subsitute
>> for a real MM-relation. I'm not sure, whether ExtBase can handle comma
>> seperated lists in its persistence classes (I think so, as there is an
>> example for fe_users and fe_groups shipped with ExtBase), but I would
>> strongly recommend to use real M:M tables to solve this problem.
>>
>> In my extension, MM tables are correctly resolved!
>>
>> Greetings
>>
>> Michael
>>
>>
>>
>>
>> Eat Dimanche schrieb:
>>> Hi,
>>>
>>> >> I have two tables have relationship to each other: "member" &
>>> "service". For each member can have 1..* on service.
>>>
>>> >> In table member I have stored the services separately by comma.
>>> For example:
>>>
>>> >> table member
>>> -----------------------
>>> uid name service
>>> -----------------------
>>> 1 Sok 1,2
>>> 2 Sao 2,3
>>> 3 Dimanche 4
>>> -----------------------
>>>
>>> >> table service
>>> -------------
>>> uid name
>>> -------------
>>> 1 AA
>>> 2 BB
>>> 3 CC
>>> 4 DD
>>> 5 EE
>>> -------------
>>>
>>> >> I am working in the backend it works properly. But now, I would like
>>> to update service in the frontend. I can't. The value always be null
>>> in database when I updated.
>>> >> For editing form I am using multiple selection box. For property
>>> service is assigned type as Tx_Extbase_Persistence_ObjectStorage,
>>> also method getter and setter same relatedPosts.
>>>
>>>
>>> Could anyone help me for this problem?
>>> Thanks a lot.
>>>
>>> Best regards,
>>> Dimanche
>> _______________________________________________
>> 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