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 int[]
getPlaceholderPositions(string $statement, bool $isPositional = true)

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

static mixed[]
expandListParameters(string $query, mixed[] $params, int[]|string[] $types)

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

Details

static int[] getPlaceholderPositions(string $statement, bool $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
bool $isPositional

Return Value

int[]

static mixed[] expandListParameters(string $query, mixed[] $params, int[]|string[] $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.
mixed[] $params The parameters to bind to the query.
int[]|string[] $types The types the previous parameters are in.

Return Value

mixed[]

Exceptions

SQLParserUtilsException