class SQLParserUtils (View source)

Utility class that parses sql statements with regard to types and parameters.

Constants

POSITIONAL_TOKEN

NAMED_TOKEN

ESCAPED_SINGLE_QUOTED_TEXT

ESCAPED_DOUBLE_QUOTED_TEXT

ESCAPED_BACKTICK_QUOTED_TEXT

ESCAPED_BRACKET_QUOTED_TEXT

Methods

static array
getPlaceholderPositions(string $statement, boolean $isPositional = true)

Gets an array of the placeholders in an sql statements as keys and their positions in the query string.

static array
expandListParameters(string $query, array $params, array $types)

For a positional query this method can rewrite the sql statement with regard to array parameters.

Details

static array getPlaceholderPositions(string $statement, boolean $isPositional = true)

Gets an array of the placeholders in an sql statements as keys and their positions in the query string.

Returns an integer => integer pair (indexed from zero) for a positional statement and a string => int[] pair for a named statement.

Parameters

string $statement
boolean $isPositional

Return Value

array

static array expandListParameters(string $query, array $params, array $types)

For a positional query this method can rewrite the sql statement with regard to array parameters.

Parameters

string $query The SQL query to execute.
array $params The parameters to bind to the query.
array $types The types the previous parameters are in.

Return Value

array

Exceptions

SQLParserUtilsException