final class PdoTransaction implements TransactionInterface (View source)

Transaction control over the request's PDO handle, the one the repositories write through.

Methods

__construct(PDO $db)

No description

void
begin()

SQLite gets BEGIN IMMEDIATE. PDO issues a deferred BEGIN, which takes no write lock, so the first write has to upgrade from a read; SQLite refuses an upgrade that could deadlock and returns "database is locked" at once, without waiting for busy_timeout. Taking the write lock at BEGIN is the one form SQLite will wait for, so a competing writer queues than fails.

void
commit()

No description

void
afterCommit(string $key, callable $work)

Runs $work once the open transaction commits, and never if it rolls back; at once when none is open. A repeated $key replaces the earlier work, so a zone is pushed once however many writes touched it. For calls that must not run while locks are held, such as HTTP.

void
rollBack()

No description

bool
inTransaction()

PDO cannot see a transaction opened with a raw statement, so both are reported. Everything that decides whether to open its own transaction must ask this rather than PDO directly.

Details

__construct(PDO $db)

No description

Parameters

PDO $db

void begin()

SQLite gets BEGIN IMMEDIATE. PDO issues a deferred BEGIN, which takes no write lock, so the first write has to upgrade from a read; SQLite refuses an upgrade that could deadlock and returns "database is locked" at once, without waiting for busy_timeout. Taking the write lock at BEGIN is the one form SQLite will wait for, so a competing writer queues than fails.

Return Value

void

void commit()

No description

Return Value

void

void afterCommit(string $key, callable $work)

Runs $work once the open transaction commits, and never if it rolls back; at once when none is open. A repeated $key replaces the earlier work, so a zone is pushed once however many writes touched it. For calls that must not run while locks are held, such as HTTP.

Parameters

string $key
callable $work

Return Value

void

void rollBack()

No description

Return Value

void

bool inTransaction()

PDO cannot see a transaction opened with a raw statement, so both are reported. Everything that decides whether to open its own transaction must ask this rather than PDO directly.

Return Value

bool