Accessing the Database

The TYPO3 database should always be accessed using the QueryBuilder of doctrine. The ConnectionPool class can be used to create a QueryBuilder instance:

use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tablename');

See the Database Access API documentation for more details.