final |
|---|
The SQL parser that focuses on identifying prepared statement parameters. It implements parsing other tokens like string literals and comments only as a way to not confuse their contents with the the parameter placeholders.
The parsing logic and the implementation is inspired by the PHP PDO parser.
| Methods | ||
|---|---|---|
public
|
__construct(bool $mySQLStringEscaping)
|
# |
public
|
parse(string $sql, Visitor $visitor): void
|
# |
private
|
getMySQLStringLiteralPattern(string $delimiter): string
|
# |
private
|
getAnsiSQLStringLiteralPattern(string $delimiter): string
|
# |
| Constants | ||
|---|---|---|
private
|
SPECIAL_CHARS = ':\?\'"`\\[\\-\\/'
|
# |
private
|
BACKTICK_IDENTIFIER = '`[^`]*`'
|
# |
private
|
BRACKET_IDENTIFIER = '(?<!\b(?i:ARRAY))\[(?:[^\]])*\]'
|
# |
private
|
MULTICHAR = ':{2,}'
|
# |
private
|
NAMED_PARAMETER = ':[a-zA-Z0-9_]+'
|
# |
private
|
POSITIONAL_PARAMETER = '(?<!\\?)\\?(?!\\?)'
|
# |
private
|
ONE_LINE_COMMENT = '--[^\r\n]*'
|
# |
private
|
MULTI_LINE_COMMENT = '/\*([^*]+|\*+[^/*])*\**\*/'
|
# |
private
|
SPECIAL = '[' . self::SPECIAL_CHARS . ']'
|
# |
private
|
OTHER = '[^' . self::SPECIAL_CHARS . ']+'
|
# |
| Properties | |||
|---|---|---|---|
private
|
string
|
$sqlPattern
|
# |