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

The ORDER BY, LIMIT, OFFSET, FETCH and locking clauses written after a query body.

Mirrors the sortClause, limitOffset, limitCount, limitOption and lockingClause that PostgreSQL attaches to a SelectStmt. The locking clauses may be written before or after the limit; the order is kept. FOR READ ONLY requests no lock. An integer constant in ORDER BY is an output position and must be given as one. Source: https://www.postgresql.org/docs/17/sql-select.html.

Reading the options of a selectiondoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 1 ORDER BY 1 FOR UPDATE LIMIT 1');
    [count($query->statement->options->order), $query->statement->options->lockingFirst, $query->toString()] // => [1, true, 'SELECT 1 ORDER BY 1 FOR UPDATE LIMIT 1']
Refusing an integer constant that is not given as a positiondoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Query\Clause\SelectOptions([new \SqlSemantics\Platform\PostgreSql\Statement\Query\SortItem(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('1')))]) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public list<SortItem> $order
public list<LockingClause> $locking
public RowLimit|null $limit = null
public bool $readOnly = false
public bool $lockingFirst = false

Methods§

public function __construct(
    list<SortItem> $order = [],
    public RowLimit|null $limit = null,
    list<LockingClause> $locking = [],
    public bool $readOnly = false,
    public bool $lockingFirst = false,
)

Parameters

$orderlist<SortItem>The ORDER BY items in written order
$limitRowLimit|nullThe LIMIT, FETCH and OFFSET clauses
$lockinglist<LockingClause>The locking clauses in written order
$readOnlyboolWhether FOR READ ONLY is written instead of locking clauses
$lockingFirstboolWhether the locking clauses are written before the limit
Calls 6
public function locks(): bool

Tells whether locking clauses or FOR READ ONLY are written.

Returns

bool
Test cases 1
public function render(Output $out): void

Writes ORDER BY, then the limit and the locking clauses in the order written.

Parameters

$outOutput
Calls 3

Test cases 11§

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 10

Relations§

Instantiated in 1
Type declarations 15