interface SqlTransformer

Rewrites a statement so that it reads the shadow instead of the database.

A transformer holds nothing: everything it needs about a table is handed to it, so the same transformer can rewrite one statement against one shadow and the next against another.

A shadow row's values are whatever the driver handed back, which is wider than what a row holds once it has been read: a driver may answer a large column as an open stream, or an object that says how it spells itself.

Type Aliases§

ShadowView = array{viewSql: string}
ShadowRows = array{rows: array<int, array<string, mixed>>, columns: array<int, string>, columnTypes: array<string, ColumnDeclaration>, primaryKeys?: array<int, string>, candidateKeys?: array<string, array<int, string>>, partialUniqueIndexes?: array<string, PartialUniqueIndex>, columnDefaults?: array<string, string>, identityStrategies?: array<string, IdentityGenerationStrategy>, generatedExpressions?: array<string, string>, partitioning?: TablePartitioning|null, sourceSql?: string, storageTable?: string}
ShadowTable = ShadowView|ShadowRows
ShadowTables = array<string, ShadowTable>
Row = import from TableDefinition
RenderableValue = import from ValueRenderer

Methods§

public function transform(string $sql, ShadowTables $tables): string

Rewrites a statement so that it reads these tables' shadow rows.

A table given as a view is rewritten to the statement that defines it; a table given as rows is rewritten to those rows written out.

Parameters

$sqlstringThe statement, as it was written
$tablesShadowTablesTable name => what the shadow holds for it

Returns

string The statement, rewritten to read the shadow

Test cases 3§

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

Dedicated tests 1
Other tests reaching this symbol 2

Relations§

Implemented by 1