[TYPO3-mvc] Tx_Extbase_Persistence_ObjectStorage problem

Sebastian Schreiber me at schreibersebastian.de
Thu Dec 31 14:51:34 CET 2009


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


-- 
Sebastian Schreiber

Sülzburgstraße 36
D-50937 Köln

T  0221 . 985 13 42
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 219 / 5302 / 2302



More information about the TYPO3-project-typo3v4mvc mailing list