我需要一个页面的所有记录,但我需要它适用于用户当前所在的特定语言和工作区。
在传统的 typo3 中,我使用了类似的东西:
$query = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'*', // SELECT ...
'tx_faqs_domain_model_faqsections', // FROM ...
'pid=' . (int) $pid . ' and deleted=0 and hidden=0 and sys_language_uid=' . $lang . ' AND t3ver_wsid = ' . (int) $workspace, // WHERE...
'', // GROUP BY...
'sorting', // ORDER BY...
'' // LIMIT ...
);
foreach ($query as $key => $value) {
$data[$key] = utf8_encode($value);
}
但是,以下不适用于工作区,并且似乎不适合新的 flow3 框架。
我看了一下:
$query = $this->createQuery();
return $query->execute();
在我的 Tx_Faqs_Domain_Repository_FaqSectionsRepository 类中,但这返回一个空数组。
从数据库表中获取特定页面、特定工作区中特定语言的所有记录的示例将是完美的。
最佳答案
向您的存储库添加一个方法来为您进行过滤:
public function findAllFromPage(){
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$pid = intval($GLOBALS['TSFE']->id);
$query->matching($query->equals('pid',$pid ));
return $query->execute();
}
重要的一点是,您将 respectStoragePage
设置为 false,否则它只是在您配置的存储 pid 中查找条目(这也是为什么像 findByPid($ GLOBALS['TSFE']->id);
,无论如何在存储库类中可用,将不起作用)
关于php - 获取数据库表 typo3 4.6.1 页面上的所有记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9668959/