[TYPO3-mvc] extbase: how to retrieve the uid of the last inserted object?

Nikolas Hagelstein lists at shr-now.de
Wed Mar 10 18:00:05 CET 2010


Hi,

> > BTW: The need to know the uid often is an indicator for akward domain
> design
> sounds interesting! why?

Depends on the particular use case.

I 've often seen people trying to use domain models similar to native db
requests e.g. something like:

--
$newUser = t3lib_div::makeInstance('Tx_Whatever_Domain_Model_User');
$newUser.setX...
...
...
$userRepository->add($newUser);
t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
$persistenceManager->persistAll();

$uid = $newItem->getUid();

$relatedItem->setUserUid($uid);
t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
$persistenceManager->persistAll();
--

Things like that can be handled by extbase internally so there is normally -
by now -
no need to persist or create relations by hand (except for some special
circumstances - complex queries, workarounds etc.).

Cheers,
Nikolas





More information about the TYPO3-project-typo3v4mvc mailing list