Actions
Feature #104561
openUse TYPO3 Connection in transactional
Status:
New
Priority:
Should have
Assignee:
Category:
Database API (Doctrine DBAL)
Target version:
Start date:
2024-08-06
Due date:
% Done:
0%
Estimated time:
PHP Version:
8.3
Tags:
Complexity:
easy
Sprint Focus:
Description
Hello,
I just found method Connection::transactional(). You can use it like that:
$connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); $queryResult = $connection->transactional(function (\Doctrine\DBAL\Connection $transactionalConnection) use ($sql): ?Result { try { $transactionalConnection->executeStatement('SET profiling=1;'); $transactionalConnection->executeQuery($sql); return $transactionalConnection->executeQuery('SHOW profile;'); } catch (Exception $e) { } return null; });
As you see you have to use the Doctrine Connection object within the Callable. Else phpstan will fail.
What do you think? Can we implement our own interpretation of transactional into TYPO3 Connection where the Callables argument is of type TYPO3 Connection?
Nice greeting
Stefan
Actions