interface ValueRenderer

Writes a PHP value as the SQL expression a dialect would read it back from.

A shadow row is written into the statement itself, so every value has to survive the round trip as the value it was. What that takes differs by dialect -- what quotes a string, what writes bytes, what a literal's type is taken to be -- which is why each dialect has its own.

Type Aliases§

RenderableValue = bool|float|int|string|Stringable|resource|null

Methods§

public function renderValue(mixed $value, ColumnDeclaration|null $type = null): string

Writes a value as the SQL that reads it back.

The column's declaration is what says how the database will read the literal, so where it is known the value is cast to it. Where it is not, the value's own PHP type is all there is to go on.

What arrives here is whatever a driver answered or a fixture was written with, which is not something ZTD can promise anything about -- so this is where anything no literal could carry is refused.

Parameters

$valuemixedValue to write, as a driver or a fixture handed it over
$typeColumnDeclaration|nullHow the column holding it was declared, or null where nothing declared it

Returns

string SQL reading that value back

Test cases 1§

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

Other tests reaching this symbol 1

Relations§

Implemented by 1