Accessing the Database

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

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

See the Database Access API documentation for more details.