2014-02-26 38 views
1

做新的東西之前,我想我的調度任務從數據庫中刪除所有條目,在執行功能看起來像這樣:使用的removeAll()

public function execute() { 

    $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); 
    $jobRepository = $objectManager->get('\TYPO3\MyExtension\Domain\Repository\JobRepository'); 

    //clear DB 
    $jobRepository->removeAll(); 

    (...)//insert new entries to DB 

    $objectManager->get('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface')->persistAll(); 

    return true; 
} 

插入新的條目到數據庫工作正常,但清理數據庫根本不起作用。我究竟做錯了什麼?

回答

5

由於removeAll()電話findAll()

public function removeAll() { 
     foreach ($this->findAll() AS $object) { 
      $this->remove($object); 
     } 
    } 

最有可能findAll()返回任何對象。你是否處理存儲空間?禁用它或手動傳遞它。如果您使用調度程序上下文中的存儲庫方法,則它不會僅存在於此。

+0

謝謝,那就是問題! – sinini