0
我有控制器索引操作的代碼。如何在數據庫中設置和保存數據在typo3中
public function indexAction() {
$this->initContentObject();
$titleforSocial = $GLOBALS['TSFE']->page['title'];
$uidforSocial = $GLOBALS['TSFE']->page['uid'];
$pidforSocial = $GLOBALS['TSFE']->page['pid'];
echo "title: ".$titleforSocial . " uid: ". $uidforSocial . " pid:" .$pidforSocial;
$elementUid = $this->cObj->data['_LOCALIZED_UID'] ? $this->cObj->data['_LOCALIZED_UID'] : $this->cObj->data['uid'];
$buttonResults = $this->contentRepository->findByIdentifier($elementUid);
$pagesResults = $this->pagesRepository->findByIdentifier($elementUid);
$button_text = $buttonResults->getButtontext();
$page_title = $pagesResults->setTitle('testing...');
var_dump($button_text);
$pagesResultsz = $this->pagesRepository->findByIdentifier($elementUid);
var_dump($pagesResultsz);
exit;
$button_text = $this->cObj->data['buttonText'];
$this->view->assign("button_text", $button_text);
}
我的主要問題是如何使用set model方法將數據保存到數據庫中。當我轉儲但不保存到數據庫時,當前設置'測試...'。 我正在使用typo3 7.6
我已經嘗試過這種 $這個 - > pagesRepository->更新($ pagesResults); 但它只是設置值,並不保存到數據庫。 我是否需要在我的倉庫中定義update()? – NK143
如果您的存儲庫擴展'Repository',則不需要。嘗試注入'PersistenceManager'並將對象傳遞給'update()'調用'$ this-> persistanceManager-> persistAll();'。 – marian0
你能告訴我什麼是PersistenceManager和我們爲什麼使用它? 我是typo3的新手,所以不太瞭解它。 – NK143