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 release(string $name): void

Gives up a named savepoint, keeping everything done since it.

Parameters

$namestringSavepoint to give up
Test cases 3
Calls 2
public function positionOf(string $name): int|null

Answers where a named savepoint is, counting the innermost first.

A name declared more than once names the innermost of them, which is the one a rollback goes back to.

Parameters

$namestringSavepoint to look for

Returns

int|null Its position, or null when nothing is declared under that name
Test cases 10
Called from 3
Calls 1

Private surface 3§

Implementation details, listed for orientation only.

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

Test cases 20§

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 12

Relations§

Instantiated in 1
Method calls 3
Constant reads 1
Type declarations 2