Doctrine\DBAL\SQLParserUtils
Utility class that parses sql statements with regard to types and parameters.
- Author: Benjamin Eberlei <kontakt@beberlei.de>
- License: http://www.opensource.org/licenses/lgpl-license.php LGPL
Synopsis
class SQLParserUtils
{
- // constants
- const POSITIONAL_TOKEN = '\?';
- const NAMED_TOKEN = '(?<!:):[a-zA-Z_][a-zA-Z0-9_]*';
- const ESCAPED_SINGLE_QUOTED_TEXT = "'(?:[^'\\\\]|\\\\'|\\\\\\\\)*'";
- const ESCAPED_DOUBLE_QUOTED_TEXT = '"(?:[^"\\\\]|\\\\"|\\\\\\\\)*"';
- // methods
- public static array getPlaceholderPositions()
- public static array expandListParameters()
- private static array getUnquotedStatementFragments()
- private static mixed extractParam()
Constants
Name | Value |
---|---|
POSITIONAL_TOKEN | '\?' |
NAMED_TOKEN | '(?<!:):[a-zA-Z_][a-zA-Z0-9_]*' |
ESCAPED_SINGLE_QUOTED_TEXT | "'(?:[^'\\\\]|\\\\'|\\\\\\\\)*'" |
ESCAPED_DOUBLE_QUOTED_TEXT | '"(?:[^"\\\\]|\\\\"|\\\\\\\\)*"' |
Methods
private
- extractParam()
- getUnquotedStatementFragments() — Slice the SQL statement around pairs of quotes and return string fragments of SQL outside of quoted literals.
public
- expandListParameters() — For a positional query this method can rewrite the sql statement with regard to array parameters.
- getPlaceholderPositions() — Get an array of the placeholders in an sql statements as keys and their positions in the query string.