getConnection(true); $connection->transaction(function (Connection $db): void { // create table will cause the transaction to be implicitly committed // (see https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html) $name = 'test_implicit_transaction_table'; $db->createCommand()->createTable($name, ['id' => 'pk'])->execute(); $db->createCommand()->dropTable($name)->execute(); }); // If we made it this far without an error, then everything's working } }