【问题标题】:How do I get records from ohter languages in a backend Modul如何在后端模块中获取其他语言的记录
【发布时间】:2019-07-31 13:49:45
【问题描述】:

我尝试在后端模块中列出来自其他语言的记录。到目前为止我试过这个

    public function findAllByLang($lang)
    {
        $query = $this->createQuery();
        $query->matching(
            $query->logicalAnd(
                [
                    $query->equals('sysLanguageUid', $lang)
                ]
            )
        );
        return $query->execute();
    }

但是我从 FrontendGroupRestriction.php 收到一个错误 以下是完整的错误信息:

致命错误:未捕获的 TypeError:explode() 期望参数 2 为字符串,/typo3_src-8.7.27/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGroupRestriction.php:36 中给出的 null 堆栈跟踪: #0 /typo3_src-8.7.27/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGroupRestriction.php(36): explode(',', NULL) #1 /typo3_src-8.7.27/typo3/ sysext/core/Classes/Utility/GeneralUtility.php(3968): TYPO3\CMS\Core\Database\Query\Restriction\FrontendGroupRestriction->__construct() #2 /typo3_src-8.7.27/typo3/sysext/core/Classes/数据库/查询/限制/AbstractRestrictionContainer.php(101): TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\...') #3 /typo3_src-8.7.27/typo3/sysext /core/Classes/Database/Query/Restriction/FrontendRestrictionContainer.php(47): TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer->createRestriction('TYPO3\CMS\Core\...') #4 in /typo3_src-8.7.27/typo3/sysext/core/Classes/Database/Query/Restriction/FrontendGro upRestriction.php 第 36 行

有人可以帮忙吗?

【问题讨论】:

    标签: javascript extbase typo3-8.x


    【解决方案1】:

    我的实际解决方案是这样的,并且有效:

    public function findAllByLang($lang)
    {
    
        $table = 'tx_gesurveys_domain_model_invitation';
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable($table);
        $data = $queryBuilder
            ->select('*')
            ->from($table)
            ->where($queryBuilder->expr()->eq('sys_language_uid', $lang))
            ->execute()
            ->fetchAll();
    
        return $data;
    }
    

    【讨论】:

      猜你喜欢
      • 2020-03-26
      • 2016-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-06
      • 1970-01-01
      • 2018-12-03
      • 1970-01-01
      相关资源
      最近更新 更多