final class ErrorCode
    implements Condition
    uses Snapshot
Public API: explicitly declared with @visibility public.

A MySQL error code as a condition value.

The grammar reads the code as an unsigned number (rule ulong_num of sql_yacc.yy): the leading decimal digits of a decimal or floating number (1e2 is 1, 0.5 is 0), or the digits of a hexadecimal literal; a value beyond the range of the conversion is its largest value. The code 0 is rejected (ER_WRONG_VALUE), and the server keeps the code as a 32-bit error number. Source: https://dev.mysql.com/doc/refman/8.4/en/declare-condition.html, https://github.com/mysql/mysql-server/blob/mysql-8.0.44/sql/sql_yacc.yy (rules sp_cond, ulong_num).

Holding an error codedoctest
(new \SqlSemantics\Platform\MySql\Statement\Routine\Condition\ErrorCode(new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('1051')))->code->text // => '1051'
Reading the error number the server takes from a floating numberdoctest
(new \SqlSemantics\Platform\MySql\Statement\Routine\Condition\ErrorCode(new \SqlSemantics\Platform\MySql\Statement\Literal\Numeral('1051.9e3')))->number() // => 1051

Properties§

public Numeral $code

Methods§

public function __construct(public Numeral $code)

Parameters

$codeNumeralThe error code
public function valid(): bool

Tells whether the code is not 0, the value the grammar rejects.

Returns

bool
Test cases 1
Calls 2
public function number(): int

Answers the error number the server keeps: the value read by the grammar, truncated to 32 bits.

Returns

int
Test cases 1
Calls 8
public function digits(): string
public function render(Output $out): void

Writes the code.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 14§

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

Dedicated tests 5
Other tests reaching this symbol 9

Relations§

Instantiated in 1
Type checks 3
Type declarations 2