Search code examples
typo3typo3-8.xtypo3-extensionstypo3-8.7.x

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


I'm using Query builder functionality in typo3 8, Now I'm receiving this exception.

Below is my error

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

Below is my source code

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();
}

Is there anything wrong with the source code?

Thank you,


Solution

  • This may be a reason of missing \ (backslash) from the starting point of your class namespace.

    try this GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class);