如何通过用户函数在 Typo3 中实现多重连接?
How can I implement a multi join in Typo3 via userfunction?
我想执行以下 sql 查询:
SELECT title
FROM sys_category
JOIN sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local
JOIN tt_content ON sys_category_record_mm.uid_foreign = tt_content.uid
WHERE tt_content.uid = 645
如果我直接通过 phpmyadmin 执行此查询,它可以正常工作,但如果我通过 userfunction 尝试执行以下操作,则 $row 的内容为 false,因此我认为我的多连接语法一定是错误的。希望你能帮助我:)
public function getCategories()
{
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery
(
'title',
'sys_category JOIN sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local JOIN tt_content ON sys_category_record_mm.uid_foreign = tt_content.uid',
'sys_category.uid = 645'
);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc( $res );
var_dump( $row );
}
我的错,问题是,我用过
'sys_category.uid = 645'
而不是
'tt_content.uid = 645'
我想执行以下 sql 查询:
SELECT title
FROM sys_category
JOIN sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local
JOIN tt_content ON sys_category_record_mm.uid_foreign = tt_content.uid
WHERE tt_content.uid = 645
如果我直接通过 phpmyadmin 执行此查询,它可以正常工作,但如果我通过 userfunction 尝试执行以下操作,则 $row 的内容为 false,因此我认为我的多连接语法一定是错误的。希望你能帮助我:)
public function getCategories()
{
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery
(
'title',
'sys_category JOIN sys_category_record_mm ON sys_category.uid = sys_category_record_mm.uid_local JOIN tt_content ON sys_category_record_mm.uid_foreign = tt_content.uid',
'sys_category.uid = 645'
);
$row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc( $res );
var_dump( $row );
}
我的错,问题是,我用过
'sys_category.uid = 645'
而不是
'tt_content.uid = 645'