final class SqlMode
Public API: explicitly declared with @visibility public.

The parts of MySQL's sql_mode that change how text is tokenized.

Reading double quotes as identifiersdoctest
$mode = new \SqlParser\MySql\SqlMode(ansiQuotes: true);
    $parser = new \SqlParser\MySql\MySqlParser(mode: $mode);
    $parser->tokenize('SELECT "x"')[1]->name // => 'IDENT_QUOTED'
Reading the mode a session reportsdoctest
$mode = \SqlParser\MySql\SqlMode::fromString('ANSI,NO_BACKSLASH_ESCAPES,STRICT_TRANS_TABLES');
    [$mode->ansiQuotes, $mode->pipesAsConcat, $mode->ignoreSpace, $mode->noBackslashEscapes, $mode->highNotPrecedence] // => [true, true, true, true, false]

Properties§

public bool $ansiQuotes = false
public bool $pipesAsConcat = false
public bool $highNotPrecedence = false
public bool $noBackslashEscapes = false
public bool $ignoreSpace = false

Methods§

public function __construct(
    public bool $ansiQuotes = false,
    public bool $pipesAsConcat = false,
    public bool $highNotPrecedence = false,
    public bool $noBackslashEscapes = false,
    public bool $ignoreSpace = false,
)

Parameters

$ansiQuotesboolWhether double quotes delimit identifiers instead of strings
$pipesAsConcatboolWhether `||` is string concatenation instead of `OR`
$highNotPrecedenceboolWhether `NOT` binds as tightly as `!`
$noBackslashEscapesboolWhether a backslash in a string is an ordinary character
$ignoreSpaceboolWhether a function name may be followed by spaces before its parenthesis
public static function default(): self

Answers the mode a fresh MySQL server runs with.

Returns

self The default mode
Test cases 2
Calls 1
public static function fromString(string $modes): self

Reads a sql_mode value as the server reports it.

The value is a comma-separated list of mode names, in any letter case, such as SELECT @@SESSION.sql_mode answers. A combination mode, such as ANSI or one of the compatibility modes releases before 8.0 had, turns on the modes it includes, as resources/sql-modes.php records them. Names that do not change tokenization, such as STRICT_TRANS_TABLES, are read and have no effect.

Parameters

$modesstringThe `sql_mode` value

Returns

self The flags the value turns on
Test cases 4
Called from 1
Calls 7

Private surface 1§

Implementation details, listed for orientation only.

private static array<string, list<string>>|null $combinations = null

Test cases 47§

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

Dedicated tests 6
Other tests reaching this symbol 41

Relations§

Instantiated in 3
Static calls 1
Type declarations 4