首页 > 解决方案 > 我想在打字稿选择查询中获取一个变量

问题描述

标题说明了一切; 我需要一个带有动态 WHERE 子句的 Typoscript SQL SELECT 查询。

我通过以下方式获取当前登录用户的 UID:

data = TSFE:fe_user|user|uid

但是我如何在数据库查询中使用它呢?

我将 UID 存储在一个名为{userID}.

到目前为止,这是我的代码。问题是 Typoscript 只是合并这两个值:

// User One has value: 50
// User Two has value: 32
// With this code the output is : 5032 ????

    lib.coins = CONTENT
    lib.coins {
        table = fe_users
        select {
            pidInList = 18
            where = uid
            andWhere.insertData = TSFE:fe_user|user|uid
            selectFields = coins
        }
        renderObj = COA
        renderObj {
            1 = TEXT
            1.field = coins
    
        }
    }

标签: variablestypo3typoscriptfluid-layouttypo3-9.x

解决方案


您应该使用以下select选项markers

lib.coins = CONTENT
lib.coins {
    table = fe_users
    select {
        selectFields = coins
        pidInList = 18
        where = uid = ###UID###

        markers {
            UID.data = TSFE:fe_user|user|uid
        }
    }
    renderObj = COA
    renderObj {
        1 = TEXT
        1.field = coins
    }
}

推荐阅读