final class BindParameter
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A bind parameter: a placeholder for a value supplied when the statement runs.

Rule: SQLITE-PARAMETER-001. The parameter is identified by its prefix and its label: no label for an anonymous ?, digits for ?NNN, a name for the other prefixes. Its type and NULL fact depend on the bound value. Source: https://sqlite.org/lang_expr.html#parameters. Status: Implemented.

Reading a numbered parameterdoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT ?2');
    [$query->statement->columns[0]->expression->label, $query->field(0)->type->missing[0]->marker] // => ['2', '?2']
Refusing a label that would not be read back as one parameterdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Colon, 'a b') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction
Refusing letters after a question markdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Question, 'ab') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction
Refusing an empty named labeldoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Colon, '') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction
Refusing a label with whitespacedoctest
new \SqlSemantics\Platform\Sqlite\Statement\Expression\BindParameter(\SqlSemantics\Platform\Sqlite\Statement\Expression\ParameterPrefix::Dollar, 'a b') // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public string $label = ''

Methods§

public function __construct(public ParameterPrefix $prefix, public string $label = '')

Parameters

$prefixParameterPrefixThe prefix character
$labelstringThe text after the prefix: empty or digits after a question mark, a name otherwise
Calls 3
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives facts that depend on the bound value.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 5
public function render(Output $out): void

Writes the parameter.

Parameters

$outOutput
Calls 2

Test cases 9§

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

Dedicated tests 3
Other tests reaching this symbol 6

Relations§

Instantiated in 1
Constant reads 2
Type checks 2
Type declarations 1