classSqlMode
final class SqlMode
Public API: explicitly declared with
@visibility public.The parts of MySQL's sql_mode that change how text is tokenized.
$mode = new \SqlParser\MySql\SqlMode(ansiQuotes: true);
$parser = new \SqlParser\MySql\MySqlParser(mode: $mode);
$parser->tokenize('SELECT "x"')[1]->name // => 'IDENT_QUOTED'$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 = falsepublic bool $pipesAsConcat = falsepublic bool $highNotPrecedence = falsepublic bool $noBackslashEscapes = falsepublic bool $ignoreSpace = falseMethods§
public function __construct(
public bool $ansiQuotes = false,
public bool $pipesAsConcat = false,
public bool $highNotPrecedence = false,
public bool $noBackslashEscapes = false,
public bool $ignoreSpace = false,
)Parameters
$ansiQuotes | bool | Whether double quotes delimit identifiers instead of strings |
$pipesAsConcat | bool | Whether `||` is string concatenation instead of `OR` |
$highNotPrecedence | bool | Whether `NOT` binds as tightly as `!` |
$noBackslashEscapes | bool | Whether a backslash in a string is an ordinary character |
$ignoreSpace | bool | Whether a function name may be followed by spaces before its parenthesis |
public static function default(): selfAnswers the mode a fresh MySQL server runs with.
Returns
self The default modeTest cases 2
Calls 1
- new
selfline 52
public static function fromString(string $modes): selfReads 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
$modes | string | The `sql_mode` value |
Returns
self The flags the value turns onTest cases 4
Called from 1
Private surface 1§
Implementation details, listed for orientation only.
private static array<string, list<string>>|null $combinations = nullTest cases 47§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
SqlModeTest::testDefaultcallsSqlModeTest::testDefaultDiffersFromAnExplicitModecallsSqlModeTest::testFromStringExpandsAnsiLikeCombinationModescallsSqlModeTest::testFromStringExpandsTheOldClientCombinationModescallsSqlModeTest::testFromStringIgnoresCaseSpacingAndAnEmptyValuecallsSqlModeTest::testFromStringReadsTheFlagsThatChangeTokenizationcalls
Other tests reaching this symbol 41
RendererTest::testRenderHonorsMysqlLexicalModescallsFormatterTest::testFormatPreservesMysqlSqlModecallsKeywordTableTest::testLoadcallsKeywordTableTest::testLookupcallsKeywordTableTest::testLookupFollowsTheModecallsMySqlLexerTest::testNextcallsNumberScannerTest::testFractioncallsNumberScannerTest::testScancallsNumberScannerTest::testScanNotesAQualifiedIdentifierThatStartsWithADigitcallsOperatorScannerTest::testMultiCharactercallsOperatorScannerTest::testScancallsOperatorScannerTest::testScanReadsNamedParametersOnlyUnderTheNamedSyntaxcallsOperatorScannerTest::testScanRejectsAForeignCharactercallsOperatorScannerTest::testScanRejectsAParameterMarkerGluedToANamecallsOperatorScannerTest::testSeparatorcallsQuotedScannerTest::testQuotedIdentifiercallsQuotedScannerTest::testQuotedIdentifierRejectsAnUnterminatedIdentifiercallsQuotedScannerTest::testScanReadsPrefixedLiteralscallsQuotedScannerTest::testScanReadsStringsAndIdentifierscallsQuotedScannerTest::testScanRejectsAnOddHexadecimalLiteralcallsQuotedScannerTest::testStringcallsQuotedScannerTest::testStringRejectsAnUnterminatedStringcallsScanTest::testLexemecallsTriviaScannerTest::testBlockCommentcallsTriviaScannerTest::testBlockCommentRejectsAnUnterminatedCommentcallsTriviaScannerTest::testSkipDropsAVersionCommentForANewerReleasecallsTriviaScannerTest::testSkipPassesWhitespaceAndCommentscallsTriviaScannerTest::testSkipReadsAVersionCommentBodyAsSqlcallsVariableScannerTest::testAtcallsVariableScannerTest::testHostnamecallsVariableScannerTest::testIdentifierOrKeywordcallsVariableScannerTest::testIdentifierOrKeywordRejectsAMissingNamecallsVariableScannerTest::testSystemVariablecallsWordScannerTest::testDollarQuotedcallsWordScannerTest::testDollarQuotedRejectsAnUnterminatedStringcallsWordScannerTest::testIdentifiercallsWordScannerTest::testIdentifierLexemecallsWordScannerTest::testScancallsWordScannerTest::testWordKeepsAKeywordBeforeADotAsAnIdentifiercallsWordScannerTest::testWordLooksUpFunctionsAcrossSpacesUnderIgnoreSpacecallsMySqlParserTest::testTokenizeHonoursTheModecalls
Relations§
Instantiated in 3
- new SqlParser\MySql\Lexer\MySqlLexer::__construct() packages/sql-parser/src/MySql/Lexer/MySqlLexer.php:40
- new SqlParser\MySql\MySqlParser::__construct() packages/sql-parser/src/MySql/MySqlParser.php:67
- new SqlSemantics\Platform\MySql\Platform::parser() packages/sql-semantics-mysql/src/Platform.php:105
Static calls 1
Type declarations 4
- type SqlParser\MySql\Lexer\KeywordTable packages/sql-parser/src/MySql/Lexer/KeywordTable.php:61
- type SqlParser\MySql\Lexer\MySqlLexer packages/sql-parser/src/MySql/Lexer/MySqlLexer.php:40
- type SqlParser\MySql\Lexer\Scan packages/sql-parser/src/MySql/Lexer/Scan.php:40
- type SqlParser\MySql\MySqlParser packages/sql-parser/src/MySql/MySqlParser.php:67