final class ShadowTransactions
    implements TransactionTarget
Public API: explicitly declared with @visibility public.

Keeps the shadow at the point each open transaction could go back to.

Nothing is sent to the database, so a transaction here is a stack of savepoints over the shadow. A nested BEGIN is ignored, because that is what a database does with one; a savepoint declared twice under the same name takes the place of the first, which is what SQL says it does.

Roll back to a named savepointdoctest
$store = new \ZtdQuery\Shadow\ShadowStore();
    $store->set('users', [['id' => 1]]);
    $transactions = new \ZtdQuery\Shadow\ShadowTransactionManager($store);
    $transactions->begin();
    $transactions->savepoint('before_insert');
    $store->insert('users', [['id' => 2]]);
    $transactions->rollBackTo('before_insert');
    $store->get('users') // => [['id' => 1]]
    $transactions->commit();

Methods§

public function __construct(
    private ShadowStore $store,
    private TableDefinitionRegistry|null $registry = null,
)

Parameters

$storeShadowStoreRows a rollback puts back
$registryTableDefinitionRegistry|nullTables a rollback puts back, where anything is describing them
public function release(string $name): void

Private surface 3§

Implementation details, listed for orientation only.

private list<ShadowSavepoint> $savepoints = []
private ShadowStore $store
private TableDefinitionRegistry|null $registry = null

Test cases 24§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 8
Other tests reaching this symbol 16

Relations§

Instantiated in 4
Method calls 3
Type declarations 2