[TYPO3-mvc] extbase: how to retrieve the uid of the last inserted object?
Nikolas Hagelstein
lists at shr-now.de
Tue Mar 9 12:13:11 CET 2010
Hi,
One way is to enforce persistence and fetch the uid afterwards e.g.:
$newItem = t3lib_div::makeInstance('Tx_Whatever_Domain_Model_Item');
$newItem = set...
...
//Assuming $itemRepository is your item repository ;).
$itemRepository->add($newItem);
//Enforce persistence
$persistenceManager =
t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
$persistenceManager->persistAll();
$uid = $newItem->getUid();
Voila....
BTW: The need to know the uid often is an indicator for akward domain design
....
Cheers,
Nikolas
More information about the TYPO3-project-typo3v4mvc
mailing list