Typo3查询生成器
我只是创建了一个SQL语句,并希望将其放入Typo3扩展中的有效查询生成器请求中 SQL是Typo3查询生成器,typo3,extbase,Typo3,Extbase,我只是创建了一个SQL语句,并希望将其放入Typo3扩展中的有效查询生成器请求中 SQL是 SELECT FROM_UNIXTIME(tx_operations_domain_model_operation.begin, '%Y') as year, count(tx_operations_operation_type_mm.`uid_foreign`) as cont, tx_operations_domain_model_type.`title` FROM tx_op
SELECT FROM_UNIXTIME(tx_operations_domain_model_operation.begin, '%Y') as year,
count(tx_operations_operation_type_mm.`uid_foreign`) as cont,
tx_operations_domain_model_type.`title`
FROM tx_operations_domain_model_operation
INNER JOIN
tx_operations_operation_type_mm ON (`tx_operations_operation_type_mm`.`uid_local` = tx_operations_domain_model_operation.uid)
INNER JOIN
tx_operations_domain_model_type ON (`tx_operations_domain_model_type`.`uid` = `tx_operations_operation_type_mm`.`uid_foreign`)
GROUP BY FROM_UNIXTIME(tx_operations_domain_model_operation.begin, '%Y'), tx_operations_operation_type_mm.`uid_foreign`;
这就是我在控制器中尝试的
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_operations_domain_model_operation');
$statement = $queryBuilder
->select('tx_operations_domain_model_operation.begin, \'%Y\') as year', 'count(tx_operations_operation_type_mm.`uid_foreign`) as cont')
->from('tx_operations_domain_model_operation')
->join(
'tx_operations_domain_model_operation',
'tx_operations_operation_type_mm',
$queryBuilder->expr()->eq('tx_operations_operation_type_mm.uid_local', $queryBuilder->quoteIdentifier('tx_operations_domain_model_operation.uid'))
)
->join(
'tx_operations_operation_type_mm',
'tx_operations_domain_model_type',
$queryBuilder->expr()->eq('tx_operations_domain_model_type.uid_local', $queryBuilder->quoteIdentifier('tx_operations_operation_type_mm.uid_foreign'))
)
->groupBy('UNIXTIME(tx_operations_domain_model_operation.begin, \'%Y\')', 'tx_operations_operation_type_mm.`uid_foreign')
->execute();
你知道query builder表示形式应该是什么样子吗?我在实习期间一直在玩QueryBuilder,我想你缺少了一个别名:
->join(
'tt_content_orig',
'sys_language',
'sys_language', /** Insert alias name, in this case it's the same name **/
$queryBuilder->expr()->eq(
'tt_content_orig.sys_language_uid',
$queryBuilder->quoteIdentifier('sys_language.uid')
)
我一直在处理存储库文件。您应该发布一段代码片段,以展示您迄今为止所做的尝试。这样,人们可以给您提供更具体的帮助。您确定可以在控制器中启动数据库查询吗?我建议在存储库中处理这个问题。这至少是一种更好的实践,可能会产生有效的代码。