[TYPO3-mvc] When do things actually get written to the database?

Nikolas Hagelstein hagelstein at shr.cc
Tue Jul 21 09:06:56 CEST 2009


Hi,

I got the following controller action
---
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);

Cheers,
Nikolas 





More information about the TYPO3-project-typo3v4mvc mailing list