Transactional
in package
FinalYes
The Transactional attribute.
Annotate your methods with the Transactional
attribute and they will be executed in a transaction.
By default, all exceptions will cause a rollback. This behavior can be changed in the configuration file.
Attributes
- #[Attribute]
- \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE
Table of Contents
Properties
- $attempts : int
- $connection : string|null
- $noRollbackFor : array<string|int, mixed>
- $rollbackFor : array<string|int, mixed>
Methods
- __construct() : mixed
- Create a new instance.
- getRollbackFor() : array<int, Throwable>>
- Get the exception types that should cause a rollback.
Properties
$attempts read-only
public
int
$attempts
= 1
$connection read-only
public
string|null
$connection
= null
$noRollbackFor read-only
public
array<string|int, mixed>
$noRollbackFor
= []
$rollbackFor read-only
public
array<string|int, mixed>
$rollbackFor
= []
Methods
__construct()
Create a new instance.
public
__construct([string|null $connection = null ][, int<1, max> $attempts = 1 ][, array<int, Throwable>> $rollbackFor = [] ][, array<int, Throwable>> $noRollbackFor = [] ]) : mixed
Parameters
- $connection : string|null = null
-
The database connection name
- $attempts : int<1, max> = 1
-
The number of times to attempt the transaction when a deadlock occurs
- $rollbackFor : array<int, Throwable>> = []
-
The exception types that should cause a rollback
- $noRollbackFor : array<int, Throwable>> = []
-
The exception types that should not cause a rollback
getRollbackFor()
Get the exception types that should cause a rollback.
public
getRollbackFor() : array<int, Throwable>>
Return values
array<int, Throwable>> —The exception types that should cause a rollback