我需要一个页面的所有记录,但我需要它为用户当前所在的特定语言和工作空间工作。
在传统的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类中,但这将返回一个空数组。
从db表中获取特定语言在特定工作空间中的特定页面的所有记录的示例将是完美的。
发布于 2012-03-13 06:19:40
将一个方法添加到您的存储库,它将为您执行过滤:
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);这样的神奇函数无法工作的原因,该函数在repository类中可用)
https://stackoverflow.com/questions/9668959
复制相似问题