[TYPO3-mvc] When do things actually get written to the database?
Jochen Rau
jochen.rau at typoplanet.de
Tue Jul 21 09:33:53 CEST 2009
Hi Nikolas.
Nikolas Hagelstein wrote:
> Public function indexAction (ArrayObject $items = NULL){
> $itemRepsotory =
> t3lib_div::makeInstance('Tx_MyExt_Domain_Model_itemRepository');
> if($items != NULL) {
> foreach ($items as $uid) {
> $currentItem = $itemRepository->findByUid($uid);
> $currentItem->setState(0);
> $itemRepository->replace($currentItem,
> $currentItem);
> }
>
> }
>
> $this->view->assign('items', $itemRepository->findByState(1))
> }
> ---
>
> Well the funny (or perhaps obvious - but not to me) - thing is that
> 'itemRepository->findByState(1))' also returns items that have been
> update a few lines above. The plugin itself is uncached. So is there a
> way to force immediate write on replace?. Or did I miss something else?
> Would be interesting as well if there is a better way to update records
> than: replace($currentItem, $currentItem);
I stumbled over a few typos:
"$itemRepsotory" should be "$itemRepository"
"Tx_MyExt_Domain_Model_itemRepository" should be
"Tx_MyExt_Domain_Model_ItemRepository" (no bug; only convention)
What do you intend to do with
$itemRepository->replace($currentItem, $currentItem); ?
I don't think you need this as $currentItem is only a reference and not
the object "itself".
I don't know what is stored in $items?
So, I am not really sure if this is a bug. May you please do some
further testing and reporting?
Regards
Jochen
--
Every nit picked is a bug fixed
More information about the TYPO3-project-typo3v4mvc
mailing list