enumParameterSyntax
enum ParameterSyntax
Public API: explicitly declared with
@visibility public.Which parameter markers a lexer reads as bound parameters.
A server has its own markers, such as ? or $1. A named placeholder, :name, is the other common way to bind a parameter in an application, and a server that has no such marker rejects it. The named syntax reads :name as a parameter where the server itself would not; a server that reads it already is unaffected.
\SqlParser\Lexer\ParameterSyntax::Named->namedLength('WHERE id = :id', 11) // => 3\SqlParser\Lexer\ParameterSyntax::Native->namedLength(':id', 0) // => 0Cases§
case NativeOnly the markers the server itself reads.
case NamedThe server's markers and the named placeholder :name.
Methods§
public function namedLength(string $source, int $offset): intReports whether the text at an offset spells a named placeholder.
A name is : followed by letters, digits and underscores; :: and := are not names.
Parameters
$source | string | The SQL text |
$offset | int | Where the colon is |
Returns
int The length of the marker, or 0 when none starts thereCalls 3
- class-const ParameterSyntax::Named() line 48
- function-call
preg_matchline 48 - function-call
strlenline 52
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 4
OperatorScannerTest::testScanReadsNamedParametersOnlyUnderTheNamedSyntaxcallsMySqlParserTest::testParseReadsNamedParametersUnderTheNamedSyntaxcallsOperatorScannerTest::testScanReadsNamedParametersOnlyUnderTheNamedSyntaxcallsPostgreSqlParserTest::testParseReadsNamedParametersUnderTheNamedSyntaxcalls
Relations§
Constant reads 10
- class-const SqlParser\MySql\Lexer\MySqlLexer::__construct() packages/sql-parser/src/MySql/Lexer/MySqlLexer.php:47
- class-const SqlParser\MySql\Lexer\Scan::__construct() packages/sql-parser/src/MySql/Lexer/Scan.php:42
- class-const SqlParser\MySql\MySqlParser::__construct() packages/sql-parser/src/MySql/MySqlParser.php:67
- class-const SqlParser\PostgreSql\Lexer\PostgreSqlLexer::__construct() packages/sql-parser/src/PostgreSql/Lexer/PostgreSqlLexer.php:37
- class-const SqlParser\PostgreSql\Lexer\Scan::__construct() packages/sql-parser/src/PostgreSql/Lexer/Scan.php:26
- class-const SqlParser\PostgreSql\PostgreSqlParser::__construct() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:63
- class-const SqlSemantics\Platform\MySql\Platform::parser() packages/sql-semantics-mysql/src/Platform.php:108
- class-const SqlSemantics\Platform\MySql\Platform::parser() packages/sql-semantics-mysql/src/Platform.php:108
- class-const SqlSemantics\Platform\PostgreSql\Platform::parser() packages/sql-semantics-postgres/src/Platform.php:92
- class-const SqlSemantics\Platform\PostgreSql\Platform::parser() packages/sql-semantics-postgres/src/Platform.php:92
Type declarations 6
- type SqlParser\MySql\Lexer\MySqlLexer packages/sql-parser/src/MySql/Lexer/MySqlLexer.php:47
- type SqlParser\MySql\Lexer\Scan packages/sql-parser/src/MySql/Lexer/Scan.php:42
- type SqlParser\MySql\MySqlParser packages/sql-parser/src/MySql/MySqlParser.php:67
- type SqlParser\PostgreSql\Lexer\PostgreSqlLexer packages/sql-parser/src/PostgreSql/Lexer/PostgreSqlLexer.php:37
- type SqlParser\PostgreSql\Lexer\Scan packages/sql-parser/src/PostgreSql/Lexer/Scan.php:26
- type SqlParser\PostgreSql\PostgreSqlParser packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:63