class Query (View source)

Statement utilities.

Properties

static string[] $functions

Functions that set the flag is_func.

Methods

static StatementFlags
getFlags(Statement|null $statement)

Gets an array with flags this statement has.

static StatementInfo
getAll(string $query)

Parses a query and gets all information about it.

static array
getTables(Statement $statement)

Gets a list of all tables used in this statement.

static string
getClause(Statement $statement, TokensList $list, string $clause, int|string $type = 0, bool $skipFirst = true)

Gets a specific clause.

static string
replaceClause(Statement $statement, TokensList $list, string $old, string|null $new = null, bool $onlyType = false)

Builds a query by rebuilding the statement from the tokens list supplied and replaces a clause.

static string
replaceClauses(Statement $statement, TokensList $list, array $ops)

Builds a query by rebuilding the statement from the tokens list supplied and replaces multiple clauses.

static array
getFirstStatement(string $query, string|null $delimiter = null)

Gets the first full statement in the query.

static int
getClauseStartOffset(Statement $statement, TokensList $list, string $clause)

Gets a starting offset of a specific clause.

Details

static StatementFlags getFlags(Statement|null $statement)

Gets an array with flags this statement has.

Parameters

Statement|null $statement

the statement to be processed

Return Value

StatementFlags

static StatementInfo getAll(string $query)

Parses a query and gets all information about it.

Parameters

string $query

the query to be parsed

Return Value

StatementInfo

static array getTables(Statement $statement)

Gets a list of all tables used in this statement.

Parameters

Statement $statement

statement to be scanned

Return Value

array

static string getClause(Statement $statement, TokensList $list, string $clause, int|string $type = 0, bool $skipFirst = true)

Gets a specific clause.

Parameters

Statement $statement

the parsed query that has to be modified

TokensList $list

the list of tokens

string $clause

the clause to be returned

int|string $type

The type of the search. If int, -1 for everything that was before 0 only for the clause 1 for everything after If string, the name of the first clause that should not be included.

bool $skipFirst

whether to skip the first keyword in clause

Return Value

string

static string replaceClause(Statement $statement, TokensList $list, string $old, string|null $new = null, bool $onlyType = false)

Builds a query by rebuilding the statement from the tokens list supplied and replaces a clause.

It is a very basic version of a query builder.

Parameters

Statement $statement

the parsed query that has to be modified

TokensList $list

the list of tokens

string $old

The type of the clause that should be replaced. This can be an entire clause.

string|null $new

The new clause. If this parameter is omitted it is considered to be equal with $old.

bool $onlyType

whether only the type of the clause should be replaced or the entire clause

Return Value

string

static string replaceClauses(Statement $statement, TokensList $list, array $ops)

Builds a query by rebuilding the statement from the tokens list supplied and replaces multiple clauses.

Parameters

Statement $statement

the parsed query that has to be modified

TokensList $list

the list of tokens

array $ops

Clauses to be replaced. Contains multiple arrays having two values: [$old, $new]. Clauses must be sorted.

Return Value

string

static array getFirstStatement(string $query, string|null $delimiter = null)

Gets the first full statement in the query.

Parameters

string $query

the query to be analyzed

string|null $delimiter

the delimiter to be used

Return Value

array

array containing the first full query, the remaining part of the query and the last delimiter

static int getClauseStartOffset(Statement $statement, TokensList $list, string $clause)

Gets a starting offset of a specific clause.

Parameters

Statement $statement

the parsed query that has to be modified

TokensList $list

the list of tokens

string $clause

the clause to be returned

Return Value

int