2

我有一个有效的 MySQL Query 现在我需要它来转换为 Typo3 语法

SELECT 
  tt_news_tx_extendnews_subscriber_mm.uid_local, 
  fe_users.* 
FROM fe_users
   JOIN tt_news_tx_extendnews_subscriber_mm
    ON tt_news_tx_extendnews_subscriber_mm.uid_foreign =  fe_users.uid
WHERE tt_news_tx_extendnews_subscriber_mm.uid_local = 101

TYPO3

        $res0 = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
            'tt_news_tx_extendnews_subscriber_mm.uid_local,fe_users.*',
            'fe_users',
            'tt_news_tx_extendnews_subscriber_mm',
            'tt_news_tx_extendnews_subscriber_mm.uid_foreign = fe_users.uid',
            'tt_news_tx_extendnews_subscriber_mm.uid_local = 101',
            '',
            '',
            ''
        );  

结果是空的......有人知道这如何与typo3一起使用吗?

调试带来了这个: $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;

SELECT tt_news_tx_extendnews_subscriber_mm.uid_local,fe_users.* 
    FROM fe_users,tt_news_tx_extendnews_subscriber_mm,tt_news_tx_extendnews_subscriber_mm.uid_foreign = fe_users.uid 
    WHERE fe_users.uid=tt_news_tx_extendnews_subscriber_mm.uid_local 
    AND tt_news_tx_extendnews_subscriber_mm.uid_foreign = fe_users.uid.uid=tt_news_tx_extendnews_subscriber_mm.uid_foreign tt_news_tx_extendnews_subscriber_mm.uid_local = 101
4

1 回答 1

4

exec_SELECT_mm_query第 4 个参数是外键表名,而不是引用。你需要而不是:

tt_news_tx_extendnews_subscriber_mm.uid_foreign = fe_users.uid

只要:

fe_users

在 TYPO3 api 中查看更多详细信息:exec_SELECT_mm_query

我认为,您可以尝试以下方法:

$res0 = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
            'tt_news_tx_extendnews_subscriber_mm.uid_local,fe_users.*',
            'tt_news',
            'tt_news_tx_extendnews_subscriber_mm',
            'fe_users',
            'tt_news_tx_extendnews_subscriber_mm.uid_local = 101',
            '',
            '',
            ''
        );  

或者您可以通过以下小技巧完全使用 SQL,因为exe_SELECTquery仅将您的字符串连接到SELECT..., FROM...(等等......)部分。所以正因为如此,你可以使用 a部分JOINFROM

$res0 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tt_news_tx_extendnews_subscriber_mm.uid_local,fe_users.*',
'fe_users
   JOIN tt_news_tx_extendnews_subscriber_mm
    ON tt_news_tx_extendnews_subscriber_mm.uid_foreign =  fe_users.uid',
 'tt_news_tx_extendnews_subscriber_mm.uid_local = 101',
 '',
 '',
 '');
于 2013-06-10T07:47:32.113 回答