index/src/Data/IDbTransactions.php

58 lines
1.7 KiB
PHP

<?php
// IDbTransactions.php
// Created: 2021-05-02
// Updated: 2022-02-16
namespace Index\Data;
/**
* Indicates supports for transactions in a database connection.
*/
interface IDbTransactions extends IDbConnection {
/**
* Sets whether changes should be applied immediately or whether commit should always be called first.
*
* @param bool $state true if things should automatically be committed, false if not.
*/
function setAutoCommit(bool $state): void;
/**
* Enters a transaction.
*
* @throws BeginTransactionFailedException If the creation of the transaction failed.
*/
function beginTransaction(): void;
/**
* Commits the actions done during a transaction and ends the transaction.
* A new transaction will be started if auto-commit is disabled.
*
* @throws CommitFailedException If the commit failed.
*/
function commit(): void;
/**
* Rolls back to the state before a transaction start or to a specified save point.
*
* @param ?string $name Name of the save point, null for the entire transaction.
* @throws RollbackFailedException If rollback failed.
*/
function rollback(?string $name = null): void;
/**
* Creates a save point in the transaction that can be rolled back to.
*
* @param string $name Name for the save point.
* @throws SavePointFailedException If save point creation failed.
*/
function savePoint(string $name): void;
/**
* Releases a save point.
*
* @param string $name Name of the save point.
* @throws ReleaseSavePointFailedException If releasing the save point failed.
*/
function releaseSavePoint(string $name): void;
}