final class Limit
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

The LIMIT clause: the largest number of rows to return and the number of rows to skip first.

SQLite has two spellings for a limit with an offset, LIMIT count OFFSET offset and LIMIT offset, count; the model keeps which one is written. Source: https://sqlite.org/lang_select.html#the_limit_clause.

Reading a limit written with a commadoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT a FROM t LIMIT 5, 10');
    [$query->statement->limit->offset->digits, $query->statement->limit->count->digits, $query->statement->limit->comma] // => ['5', '10', true]
Refusing the comma spelling without an offsetdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Query\Limit(new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\IntegerLiteral('1'), null, true) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public Scalar $count
public Scalar|null $offset = null
public bool $comma = false

Methods§

public function __construct(
    public Scalar $count,
    public Scalar|null $offset = null,
    public bool $comma = false,
)

Parameters

$countScalarThe largest number of rows
$offsetScalar|nullThe number of rows to skip
$commaboolWhether the offset is written first, before a comma
Calls 1
public function render(Output $out): void

Writes the clause in the spelling kept.

Parameters

$outOutput
Calls 2

Test cases 4§

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

Dedicated tests 2
Other tests reaching this symbol 2

Relations§

Instantiated in 3
Type declarations 4