[TYPO3-mvc] Get last id

Dawid Pacholczyk dpacholczyk at gmail.com
Mon Jan 17 16:01:30 CET 2011


W dniu 2011-01-17 15:31, Franz Koch pisze:
> Hi,
>
>> Ok I get it. But when I add in this way a new record to database it is
>> inserted with out pid :/
>>
>> I do something like that
>>
>> $tempRecord = t3lib_div::makeInstance('Tx_MyExt_Domain_Model_Record');
>> $tempRecord->setRUid($val['uid']);
>> $tempRecord->addPortal($portalRepository->findByUid(13));
>> $tempRecord->setTableName($table);
>> $this->add($tempRecord);
>> $persistenceManager->persistAll();
>>
>> It works great only the pid isn`t set
>
> what are you trying to achieve? Is it some sort of import module inside
> the repository class? Not sure if it belongs there - I'd rather move it
> to a import controller.

Yes it is import module. I`ve putted it into repository cause I do there 
some database operations. Thats why I thought it is a good place for that.

> Also you don't have to persist manually if you
> don't need to work with the UID of the object directly - you can also
> assign new objects directly to other objects and those get updated
> automatically when persisted (you still have to add the new object to
> the repository though).

Can you say something more about that ? I thought that I need to persist 
everything to "save" changes. I don`t get the idea of assigning new 
object to existing one if - for example - I want to import 4-5 objects 
of type Record.

>
> To your PID issue - have you defined a "storagePid" (globally for your
> extension) or probably better "newRecordStoragePid" (explicitly for your
> model) via TS?
>



The TS config solved the problem. Thank you !




More information about the TYPO3-project-typo3v4mvc mailing list