class Query (View source)

Statement utilities.

Properties

static string[] $FUNCTIONS Functions that set the flag is_func.
static array<string,false> $ALLFLAGS

Methods

static array
getFlags(Statement|null $statement, bool $all = false)

Gets an array with flags this statement has.

static array
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 $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 $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 array getFlags(Statement|null $statement, bool $all = false)

Gets an array with flags this statement has.

Parameters

Statement|null $statement the statement to be processed
bool $all if false, false values will not be included

Return Value

array

static array getAll(string $query)

Parses a query and gets all information about it.

Parameters

string $query the query to be parsed

Return Value

array

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 $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 $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 $delimiter = null)

Gets the first full statement in the query.

Parameters

string $query the query to be analyzed
string $delimiter the delimiter to be used

Return Value

array

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