#104561Use TYPO3 Connection in transactional
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
Reviews 2
Related issues 1
History 711
-
Stefan Bürk commented and changed assigned to Stefan Bürk 08/08/24, 09:36
-
Benni Mack changed target version 10/15/24, 08:19
-
Gerrit Code Review pushed patch set 1 for main to change 87675 status
NewUnder Review 01/09/25, 11:49 -
Stefan Bürk changed tracker
FeatureTask PHP Version8.38.1 TYPO3 Version 12 01/09/25, 11:49 -
Stefan Bürk commented 01/09/25, 11:49
Changed this from a feature to a task.
-
Gerrit Code Review pushed patch set 2 for main to change 87675 01/09/25, 12:12
-
Gerrit Code Review pushed patch set 3 for main to change 87675 01/09/25, 19:16
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 87693 01/10/25, 13:07
-
Stefan Bürk commented and changed status
Under ReviewResolved done0 %100 % 01/10/25, 13:20Applied in changeset commit:dd1a1d19899d67946d4f183ddb147637e8baf6d2.
-
Stefan Bürk changed Related to #105913 01/10/25, 15:13
-
Benni Mack changed status
ResolvedClosed 12/02/25, 14:33
will have a look into that.