class Query

Statement utilities.

Properties

static array $FUNCTIONS Functions that set the flag is_func.
static $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

at line 294
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

at line 396
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 The array returned is the one returned by static::getFlags(), with the following keys added: - parser - the parser used to analyze the query; - statement - the first statement resulted from parsing; - select_tables - the real name of the tables selected; if there are no table names in the SELECT expressions, the table names are fetched from the FROM expressions - select_expr - selected expressions

at line 478
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

at line 537
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

at line 669
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

at line 699
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: array($old, $new). Clauses must be sorted.

Return Value

string

at line 754
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 array containing the first full query, the remaining part of the query and the last delimiter

at line 814
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