Typo3 版本 8.x 异常 "Connection pool was not found"

Typo3 version 8.x Exception "Connection pool was not found"

我在 typo3 8 中使用查询生成器功能,现在收到此异常。

下面是我的错误

Uncaught TYPO3 Exception Class 'TYPO3\CMS\Core\Database\ConnectionPool' not found 

下面是我的源代码

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;

*
*
*

public function getItems($Variable1,$Variable2)
{
   $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_xxxxxx');
   $statement = $queryBuilder
      ->select('*')
      ->from('tx_xxxxxx AS txx')
      ->where(
          $queryBuilder->expr()->eq('txx.field_name_1',$Variable1),
          $queryBuilder->expr()->eq('txx.field_name_2',$Variable2)
      )
      ->execute();
   return $statement->fetch();
}

源码有问题吗?

谢谢,

这可能是 class 命名空间起点缺少 \(反斜杠)的原因。

试试这个GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);